akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 20;
const int INF = 0x3f3f3f3f;

int n, a[MAX_N], b[MAX_N];
struct Card
{
    int x, p;
    Card(int x=0, int p=0):x(x), p(p) {}
}c[MAX_N];
int d[MAX_N];

int solve(int S)
{
    for (int i = 0; i < n; i++)
    {
        if (S & (1<<i))
        {
            c[i] = Card(b[i], 1);
            d[i] = b[i];
        }
        else
        {
            c[i] = Card(a[i], 0);
            d[i] = a[i];
        }
    }
    sort(d, d+n);
    int ans = 0;
    for(int i = n-1; i >= 0; i--)
    {
        bool flag = false;
        for (int j = i; j >= 0; j--)
        {
            if (c[j].x == d[i] && c[j].p == (i-j&1))
            {
                flag = true;
                ans += i-j;
                for (int k = j; k < i; k++)
                {
                    c[k+1].p ^= 1;
                    swap(c[k], c[k+1]);
                }
                break;
            }
        }

        if (!flag) return INF;
    }
    return ans;
}

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

    int ans = INF;
    for (int S = 0; S < (1<<n); S++)
    {
        ans = min(ans, solve(S));
    }
    if (ans == INF) ans = -1;
    printf("%d\n", ans);
    return 0;
}


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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L[87];
    int N;
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i < 87; i++) {
        L[i] = L[i-1] + L[i-2];
    }
    cin >> N;
    cout << L[N] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int a,b,c,d,e,f,able,water,sugar;cin>>a>>b>>c>>d>>e>>f;
    a*=100;b*=100;
    int ans_sw=a,ans_s=0;
    double noudo=0,tmp;
    for(int i=0;i<=f/a;i++){
        for(int j=0;j<=f/b;j++){
            water=i*a+j*b;
            if(water==0)continue;
            if(water>f)break;
            able=water/100*e;
            for(int k=0;k<=able/c;k++){
                for(int l=0;l<=able/d;l++){
                    sugar=k*c+l*d;
                    if(sugar>able)break;
                    if(water+sugar>f)break;
                    tmp=sugar*1.0/(water+sugar);
                    if(tmp>noudo){noudo=tmp;ans_sw=water+sugar;ans_s=sugar;}
                }
            }
        }
    }
    cout<<ans_sw<<" "<<ans_s<<endl;
}


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

int N, M, D[1000][1000];
char S[1000][1000];
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 }; 
//queue<pair<int, int>> Q;
queue<tuple<int, int>> Q;

int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (S[i][j] == '#') {
				//Q.push({ i,j });
				Q.emplace(i, j);
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		int x, y;
		tie(x, y) = Q.front();
		Q.pop();
		int d = D[x][y];
		ans = d;
		for (int k = 0; k < 4; k++) {
			int px = x + dx[k];
			int py = y + dy[k];
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S[px][py] == '.') {
				//Q.push({ px,py });
				Q.emplace(px, py);
				S[px][py] = '#';
				D[px][py] = d + 1;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 9984
import Control.Monad
import Control.Applicative
import Data.List

data Point = Point {getX::Double, getY::Double, getR::Double} deriving Show

point :: Double -> Double -> Double -> Point
point x y t = Point {getX = x, getY = y, getR = t * pi / 180.0}

move :: Point -> [Double] -> Point
move p [r, t] = Point {getX = getX p + r * cos (getR p), getY = getY p + r * sin (getR p), getR = getR p - t * pi / 180.0 }

main = do
  xs <- map ( map toDbl . words . rmc) . lines <$> getContents
  mapM_ print $ solve xs

solve :: [[Double]] -> [Int]
solve xs = [(truncate . getX) lp, (truncate. getY) lp]
  where lp = foldl move (point 0 0 90) xs

toDbl :: String -> Double
toDbl s = read s

rmc :: String -> String
rmc = map (\c -> if c == ',' then ' ' else c)

Measured memory_bytes: 4284
package main

import (
	"fmt"
)

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	for i := 0; i < len(S); i++ {
		w := S[len(S)-1-i:] + S[:len(S)-1-i]
		if w == T {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

Measured memory_bytes: 512
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> ve[100005];
ll vis[100005],z;
ll dp[105][100005];

void solve()
{
    ll n=0,m=0,i=0,j=0,k=0,c=0,l=0,r=0,p=1e9+7,q=0,x=0,y=0,z=0,flag=0,sum=0;
    ll a[105]={0};
    string s,t;
    cin>>n>>k;
    dp[0][0]=1;
    for(i=1;i<=n;i++){
        cin>>a[i];
        dp[i][0]=1;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%p;
            if(j-a[i]-1>=0)
            dp[i][j]=(p + dp[i][j] - dp[i-1][j-a[i]-1])%p;
        }
    }
    cout<<dp[n][k]<<endl;
    
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 82560
#include <iostream>
#include <cstdio>

using namespace std;
static const int SIZE = 10001;
int parent[SIZE];
int rk[SIZE];

void init()
{
	for (int i = 0; i < SIZE; ++i)
	{
		parent[i] = i;
		rk[i] = 0;
	}
}

int find(int x)
{
	if (x == parent[x])
	{
		return(x);
	}
	else
	{
		return(parent[x] = find(parent[x]));
	}
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}
	if (rk[x] < rk[y])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (rk[x] == rk[y])
		{
			rk[x]++;
		}
	}
}

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

void solve()
{
	init();
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; ++i)
	{
		int com, x, y;
//		cin >> com >> x >> y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0)
		{
			unite(x, y);
		}
		else
		{
			if (same(x, y))
			{
				printf("1\n");
				//cout << 1 << endl;
			}
			else
			{
				printf("0\n");
				//cout << 0 << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int n,k;
  cin>>n>>k;

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

  rep(t,k){
    vector<int> dbdi(n+1,0);
    rep(i,n){
      dbdi[max(0,i-a[i])]++;
      dbdi[min(n,i+a[i]+1)]--;
    }
    int db=0;
    bool ch=false;
    rep(i,n){
      db+=dbdi[i];
      if(a[i]!=db) ch=true;
      a[i]=db;
    }
    if(!ch) break;
  }

  rep(i,n) cout<<a[i]<<' ';
  cout<<endl;
}

int main(){app();return 0;}


Measured memory_bytes: 4836
def find_ins_pos(a, val)
  pos = 0
  while pos < a.size and a[pos] < val do
    pos += 1
  end
  pos
end

def insertion_sort(a)
  b = []
  a.size.times { |i|
    pos = find_ins_pos(b, a[i])
    b.insert(pos, a[i])
    puts (b + a[i+1..-1]).map{|x| x.to_s}.join(" ")
  }
  b
end


def main()
  gets
  a = gets.split.map{|x| x.to_i}
  insertion_sort(a)
end

main



Measured memory_bytes: 6968
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
const int maxn=5e5;
int s[maxn];
vector <int> v[200010];
	queue <int> p;
void bfs(){
		while(!p.empty()){
		int x=p.front();
		p.pop();
		for(int i=0;i<v[x].size();i++){
//			cout<<v[x][i]<<" "; 
			if(s[v[x][i]]==0&&v[x][i]!=1){
				p.push(v[x][i]);
				s[v[x][i]]=x;
			}
		}
	}
} 
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	p.push(1);
	memset(s,0,sizeof(s));
	s[1]=1;
    bfs();
	int l=1;
	for(int i=1;i<=n;i++){
//		cout<<s[i]<<endl;
		if(s[i]==0)
		{  l=0;
		   break;
		}
	}
	if(l){
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++)
		cout<<s[i]<<endl;
	}
	else 
	cout<<"No"<<endl;
	
}

Measured memory_bytes: 13908
#!/usr/bin/env python3
import sys
import heapq
INF = float("inf")


class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, -value)

    def pop(self):
        return -heapq.heappop(self.heap)

    def __len__(self):
        return len(self.heap)


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    # 後ろから貪欲
    AB = list(zip(A, B))
    AB.sort()
    A, B = zip(*AB)
    DP = [0]
    h = MaxHeap([])
    left = 0
    for i in range(1, M+1):
        while left < N and A[left] <= i:
            h.push(B[left])
            left += 1
        if len(h) > 0:
            # print("h", h)
            b = h.pop()
            # print(b, DP[-1]+b)
            DP.append(DP[-1]+b)
        else:
            DP.append(DP[-1])
    print(DP[-1])
    # print(DP)
    # print(h)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26936
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

const int MAX = 510000;
// Calculate COM(MAX, k) for k<=MAX by O(1) after COMinit() by O(MAX)
// {{{
ll fac[MAX], finv[MAX], inv[MAX];

// 前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//}}}

int solve(){
  int N,K;cin>>N>>K;

  COMinit();

  rep(i, 1, K+1){
    int res = COM(N-K+1, i) * COM(K-1, i-1);
    cout << res%MOD << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 12160
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N = int(input())
W = list(map(int, input().split()))

ans = 10 ** 5
S1 = 0
S2 = sum(W)

for i in range(N):
	S1 += W[i]
	S2 -= W[i]
	tmp = abs(S1 - S2)
	if tmp < ans:
		ans = tmp

print(ans)


Measured memory_bytes: 38448
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

int main(){
	int n;
	std::vector<int> aList;
	long long ans=0;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	while(1){
		bool isAllZero=true;

		long long plusCount=0;

		bool isZero=(aList[0]<=0);

		for(int i=1; i<n; i++){
			if(!isZero && aList[i]<=0){
				isZero=true;
				plusCount++;
			}

			if(aList[i]>0)
				isZero=false;
		}

		if(!isZero)
			plusCount++;

		for(int i=0; i<n; i++){
			if(aList[i]>0){
				isAllZero= false;
				aList[i]--;
			}
		}

		if(isAllZero)
			break;

		ans+= plusCount;
	}

	std::cout<<ans<<std::endl;

	return 0;
	
}

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

using namespace std;

const int INF = 1e9;

int dp[1005][5005];
pair <int, int> a[1005];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    for (int i = 1; i <= m; i++) {
        int x;
        scanf("%d%d", &a[i].first, &x);

        for (int j = 0; j < x; j++) {
            int y;
            scanf("%d", &y);
            y--;
            a[i].second += (1 << y);
        }
    }

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

    dp[0][0] = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < (1 << n); j++) {
            for (int k = j; k > 0; k = (k - 1) & j) {
                if ((k | a[i].second) == j) dp[i][j] = min(dp[i][j], dp[i - 1][k] + a[i].first);
            }
            if (a[i].second == j) dp[i][j] = min(dp[i][j], dp[i - 1][0] + a[i].first);
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }

    if (dp[m][(1 << n) - 1] == INF) printf("-1\n");
    else printf("%d\n", dp[m][(1 << n) - 1]);
}


Measured memory_bytes: 19840
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


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

int main()
{
	fastio
	ll a,b,c,d;
	cin >> a >> b >> c >>d;
	cout << max({a*c,b*d,a*d,b*c}) << endl;
	return 0;	
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
vll G[N];
ll dp[N];

ll dfs(ll node)
{
	if(sz(G[node])==0)
	{
		return 0;
	}
	if(dp[node]!=-1)
	{
		return dp[node];
	}
	ll i,ans=0;
	for(i=0;i<sz(G[node]);i++)
	{
		ans=max(ans,1+dfs(G[node][i]));
	}
	dp[node]=ans;
	return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,u,v,ans,p;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
    	cin>>u>>v;
    	G[u].pb(v);
    } 
    memset(dp,-1,sizeof(dp));
    ans=0;
    for(i=1;i<=n;i++)
    {
    		p=dfs(i);
    }
    for(i=1;i<=n;i++)
    {
    	ans=max(ans,dp[i]);
    }
    cout<<ans<<"\n";
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;

  bool flag = false;
  rep(x,100)
    rep(y,100)
    if(4*x+7*y==n) flag = true;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long

int U, N, M, K[15], P[15], S[15][15];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> K[i];
		for (int j = 1; j <= K[i]; j++) cin >> S[i][j];
	}
	for (int i = 1; i <= M; i++) cin >> P[i];
	for (int i = 0; i < (1<<N); i++) {
		bool B = 0;
		for (int j = 1; j <= M; j++) {
			int T = 0;
			for (int k = 1; k <= K[j]; k++)
				if (i & (1<<(S[j][k]-1))) T++;
			if (T % 2 != P[j]) B = 1;
		}
		U += !B;
	}
	cout << U << '\n';
}


Measured memory_bytes: 256
def small_and_large_integers(A,B,K):
    if B-A+1 <= 2*K:
        for i in range(A, B+1):
            print(i)
    else:
        for i in range(K):
            print(A+i)
        for i in range(K):
            print(B-K+1+i)

def main():
    i = input()
    A,B,K = i.split()
    A,B,K = int(A), int(B), int(K)
    small_and_large_integers(A,B,K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        _n:usize,
        c:Chars,
    }
    let num_r = c.iter().filter(|x| **x == 'R').count();
    let ans = c[0..num_r].iter().filter(|x| **x == 'W').count();
    println!("{}", ans);
}

Measured memory_bytes: 3052
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 100100;

VI edges[N];

// Reference: http://cf16-relay-open.contest.atcoder.jp/submissions/1002080

int c[N];

int ma = 0;

int dfs(int v, int p) {
  VI t(2, 0);
  REP(i, 0, edges[v].size()) {
    int w = edges[v][i];
    if (w == p) {
      continue;
    }
    int r = dfs(w, v);
    t.push_back(r);
  }
  sort(t.rbegin(), t.rend());
  ma = max(ma, t[0] + t[1] + c[v]);
  c[v] += t[0];
  return c[v];
}

int main(void){
  int n;
  cin >> n;
  REP(i, 0, n - 1) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    edges[p].push_back(q);
    edges[q].push_back(p);
  }
  // Find one of the longest path and counts vertices of index two.
  REP(i, 0, n) {
    c[i] = edges[i].size() == 2 ? 1 : 0;
  }
  dfs(0, -1);
  int tot = ma;
  REP(i, 0, n) {
    if (edges[i].size() == 1) { tot++; }
  }
  cout << tot << endl;
}


Measured memory_bytes: 6272
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int h[100010][3], dp[100010][3];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n_rows, n_cols = 3;
    cin >> n_rows;
    // vector<vector<int>> h(n_rows, vector<int>(n_cols));
    REP(i, n_rows) { cin >> h[i][0] >> h[i][1] >> h[i][2]; }
    // 動的計画法の２次元配列は、前回の選択肢と幸福度を記録する
    // vector<vector<int>> dp(n_rows + 1, vector<int>(n_cols, 0));
    REP(i, n_cols) { dp[0][i] = 0; }
    REP(i, n_rows) {
        REP(j, n_cols) {
            REP(k, n_cols) {
                if (k != j) {
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + h[i][j]);
                }
            }
        }
    }
    cout << max({dp[n_rows][0], dp[n_rows][1], dp[n_rows][2]}) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm> 
using namespace std;
int a[100005],ans;
bool vis[100005];
inline int get()
{
	char c;
	int x=0,p=1;
	c=getchar();
	while (c<'0'||c>'9') {if (c=='-') p=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*p;
}
int main()
{
	int n,x,y;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	ans=1;int flag=0;
	for (int i=2;i<=n;i++)
	{
		if (a[i]==a[i-1]&&flag==0) ans--,flag=1;
		else if (a[i]!=a[i-1]||flag==1) ans++,flag=0;
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;


int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	rep(i, n) {
		cin >> m[i];
	}
	int min = INT_MAX;
	int sum = 0;
	rep(i, n) {
		sum += m[i];
		if (min > m[i]) {
			min = m[i];
		}
	}
	int count = 0;
	int res = x - sum;

	while (res >= min) {
		count++;
		res -= min;
	}
	cout << count + n << endl;

}

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

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

    string s;
    cin >> s;
    ll n = s.size();
    ll mod = 1e9 + 7;

    ll md[10][6] = {0};

    rep(i, 0, 10) {
        int k = i;
        rep(j, 0, 6) {
            md[i][j] = k % 13;
            k *= 10;
        }
    }

    ll dp[n + 1][13] = {0};
    int q = 0;
    dp[n][0] = 1;

    for (int i = n - 1; i >= 0; i--) {
        if (q == 6)
            q = 0;
        if (s[i] == '?') {
            rep(k, 0, 10) {
                rep(j, 0, 13) {
                    int l = (j + md[k][q]) % 13;
                    dp[i][l] += dp[i + 1][j];
                    dp[i][l] %= mod;
                }
            }
        } else {
            int k = s[i] - '0';
            rep(j, 0, 13) {
                int l = (j + md[k][q]) % 13;
                dp[i][l] += dp[i + 1][j];
                dp[i][l] %= mod;
            }
        }
        q++;
    }

    cout << dp[0][5] << endl;

    return 0;
}


Measured memory_bytes: 10704
// Problem : A - Study Scheduling
// Contest : AtCoder - NOMURA Programming Competition 2020
// URL : https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    lli h1,m1,h2,m2;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    x=h1*60+m1;
    y=h2*60+m2;
    if(x+k>=y){
    	cout<<"0";return;
    }
    cout<<y-x-k;
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 3600
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500*i+100*j+50*k:
                count += 1
print(count)

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	ll lb = 2, ub = 2;
	for (int i = N - 1; i >= 0; i--) {
		ll x = a[i];
		ll l = (lb + x - 1) / x;
		ll r = ub / x;
		if (l > r) {
			cout << -1 << endl;
			return 0;
		}
		lb = l * x;
		ub = (r + 1) * x - 1;
	}
	cout << lb << ' ' << ub << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int a[4][13]={{}};
    int n;
    int i;
    char A;
    int b;
    cin >>n;
    for(i=0;i<n;i++){
        cin >>A >>b;
        switch(A){
        case 'S':
           a[0][b-1]=1;
           break;
        case 'H':
           a[1][b-1]=1;
           break;
        case 'C':
           a[2][b-1]=1;
           break;
        case 'D':
           a[3][b-1]=1;
           break;
        }
    }
    for(i=0;i<52;i++){
        switch(i/13){
        case 0:
          if(a[0][i%13]==0) cout << "S " << i+1 << endl;
          break;
        case 1:
          if(a[1][i%13]==0) cout << "H " << i%13+1  << endl;
          break;
        case 2:
          if(a[2][i%13]==0) cout << "C " << i%13+1 << endl;
          break;
        case 3:
          if(a[3][i%13]==0) cout << "D " << i%13+1 << endl;
          break;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 3088
#include<iostream>
#include<cstring>
 
using namespace std;
 
int a[205];
 
int main() {
	int n;
	cin >> n;
	long long sum = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		else {
			sum += i;
		}
	}
	cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 3644
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		System.out.println("" + s.charAt(0) + (s.length() - 2) + s.charAt(s.length()-1));
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
int main(){
std::string S;
std::cin >> S;
std::cout << S[0] << S[1] << S[2] << S[3] << S[4] << " " << S[6] << S[7] << S[8] << S[9] <<S[10] << S[11] << S[12] << " " << S[14] << S[15] << S[16] << S[17] << S[18] << std::endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    string abc = "ABC";
    map<char, int>  H;
    int pos = 0;
    for(char c : abc) H[c] = pos++;

    int n;
    cin >> n;
    vector<int> x(3);
    FOR(i, 3) cin >> x[i];
    vector<string> s(n);

//    map<string, int> cnt;
    FOR(i, n) {
        cin >> s[i];
//        cnt[s[i]]++;
    }

    vector<vector<int>> nn(n+1, vector<int>(3));
    FOR(i, 3) nn[n][i] = n;
    FORI(i, n){
        nn[i] = nn[i+1];
        if (s[i] == "AB") nn[i][2] = i;
        if (s[i] == "AC") nn[i][1] = i;
        if (s[i] == "BC") nn[i][0] = i;
    }

    string ans;
    FOR(i, n){
        int p = H[s[i][0]];
        int q = H[s[i][1]];

        if ((x[p] == x[q] && nn[i+1][p] > nn[i+1][q]) || x[p] < x[q]) {
            ans += s[i][0];
            x[p]++;
            if (x[q] == 0){
                cout << "No" << endl;
                return 0;
            }
            x[q]--;
        }
        else  { //if (x[q] < x[p])
            ans += s[i][1];
            x[q]++;
            if (x[p] == 0){
                cout << "No" << endl;
                return 0;
            }
            x[p]--;
        }


        if (p == q && q == 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(char c : ans)
        cout << c << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 12176
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

void Go(ll W, ll H, ll& length){
  if(W%H==0){
    length += 2*W-H;
    return;
  }

  length += 2*(W/H)*H;
  Go(H, W-(W/H)*H, length);
  return ;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, X;
  ll length=0;
  cin >> N >> X;

  if(N==2*X){
    cout << (3*X) << "\n";
    return 0;
  }

  if(N>2*X){
    length+=N+2*X;
    Go(X, N-2*X, length);
    cout << length << "\n";
    return 0;
  }

  length += N;
  Go(X, N-X, length);
  cout << length << "\n";

  return 0;
}


Measured memory_bytes: 256
while true
  n = gets.to_f
break if n == 0

 s = gets.split.map(&:to_f)
 
 mean = s.sum / n
 sum_of_squares = s.inject(0){|sum, i| sum + (i - mean) ** 2 }
 s2 = sum_of_squares / n
 ans = Math.sqrt(s2)
 
 puts ans
end 


Measured memory_bytes: 6944
#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
using namespace std;
const int mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	while(cin >> n >> m){
		multiset<ll>st;
		f(n){
			ll add;
			cin >> add;
			st.insert(add);
		}
		while(m--){
			ll now = *(--st.end());
			st.erase(st.lower_bound(now));
			now /= 2;
			st.insert(now);
		}
		ll ans = 0;
		for(auto i:st){
			ans += i;
		}
		cout << ans << endl;
	}
}


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

int main(){
    int n;
    cin >> n;
    int x[n],y[n],h[n];
    int a_h;
    int flag;
    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> h[i];
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            flag=0;
            a_h=0;
            for(int k=0;k<n;k++){
                if(a_h==0 && h[k]>0)a_h=h[k]+abs(i-x[k])+abs(j-y[k]);
                else if(a_h>0 && h[k]>0){
                    if(a_h!=h[k]+abs(i-x[k])+abs(j-y[k])){
                        flag++;
                        break;
                    }}
                else if(a_h>0){
                    if(a_h-abs(i-x[k])-abs(j-y[k])>0){
                        flag++;
                        break;
                    }
                }
            }
            if(flag==0){
            for(int k=0;k<n;k++){
                if(h[k]>0){
                    if(a_h!=h[k]+abs(i-x[k])+abs(j-y[k])){
                        flag++;
                        break;
                    }}
                else{
                    if(a_h-abs(i-x[k])-abs(j-y[k])>0){
                        flag++;
                        break;
                    }
                }
            }}
            if(flag==0){
                cout << i << " " << j << " " << a_h << endl;
                break;
            }
        }
        if(flag==0)break;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll a[3005],dp[3005][3005],hell=998244353;
ll add(ll a,ll b){
  a+=b;
  if(a>hell)
    a-=hell;
  return a;
}
void solve(){
  ll n,s,res=0;
  cin>>n>>s;
  for(ll i=1;i<=n;i++)
    cin>>a[i];
  for(ll i=1;i<=n;i++)
    for(ll j=1;j<=s;j++){
      dp[i][j]=dp[i-1][j];
      if(j==a[i]){
        dp[i][j]=add(dp[i][j],i);
        if(j==s)
          res=add(res,(i*(n-i+1))%hell);
      }
      else if(j>a[i]){
        dp[i][j]=add(dp[i][j],dp[i-1][j-a[i]]);
        if(j==s)
          res=add(res,(dp[i-1][j-a[i]]*(n-i+1))%hell);
      }
    }
  cout<<res;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

Measured memory_bytes: 70784
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstdlib>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

bool check(string s) {
    int n = s.size();
    if (s[0] == '0') return false;
    if (s[n - 1] == '1') return false;

    for (int i = 0; i < n - 1; ++i) {
        int j = n - 2 - i;
        if (s[i] != s[j]) return false;
    }
    return true;
}

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

    string s;
    cin >> s;

    if (!check(s)) {
        cout << "-1" << endl;
        return 0;
    }

    int n = s.size();
    s = "." + s;
    s[n] = '1';


    int tapi = 1;
    for (int i = 2; i <= n; ++i) {
        if (s[i] == '1') {
            for (; tapi < i; ++tapi) {
//                cout << i << " " << tapi << endl;
                cout << tapi << " " << i << endl;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	ll disa,disb;
	disa=v*t;
	disb=w*t;
	if(disa>=disb&&disa-disb>=abs(b-a))
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,a[5010],b[5010],tot;
char s[10100];
string st[5010];
int main(){
	read(n);
	cin>>s+1;
	int k1=0,k2=0;
	for(int i=1;i<=2*n;i++)
		if(s[i]=='a') a[++k1]=i;
		else b[++k2]=i;
	for(int i=1,lst=1;i<=n;i++)
		if(i==n||max(a[i],b[i])<min(a[i+1],b[i+1]))
		if(a[i]<b[i]){
			st[++tot]="ab";
			for(int j=lst,now=b[lst];j<=i;j++)
				if(a[j]>now) st[tot]+="ab",now=b[j];
			lst=i+1;
		}
		else{
			++tot;
			for(int j=lst;j<=i;j++){
				queue<int> S;
				string now;
				for(int k=j;k<=i;k++){
					while(S.size()&&S.front()<b[k]) now+="a",S.pop();
					now+="b";
					S.push(a[k]);
				}
				while(S.size()) now+='a',S.pop();
				st[tot]=max(st[tot],now);
			}
			lst=i+1;
		}
	for(int i=tot-1;i;i--)
		st[i]=max(st[i]+st[i+1],st[i+1]);
	cout<<st[1]<<'\n';
	return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
  int N; cin>>N;
  for (int i=0; i<N; i++) cin>>h[i];
  
  for (int i=0; i<N; i++) dp[i]=INF;
  
  dp[0]=0;
  
  for (int i=1; i<N; i++) {
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if (i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N-1]<<endl;
}
                              

Measured memory_bytes: 1792
import           Data.List (foldl')
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe (fromJust)

main :: IO ()
main = do
  _ <- BS.getLine
  as <- fmap (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine
  let (_, result) = foldl' f (False, 1) as
        where
          f _ 0 = (False, 0)
          f (True, _) _ = (True, -1)
          f (False, acc) a = let temp = a * acc
                             in if temp > maxValue
                                then (True, -1)
                                else (False, temp)
      maxValue = 10 ^ (18 :: Integer)
  print result


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

using namespace std;

typedef long long ll;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<ll> cnd;

	cnd.push_back(a * c);
	cnd.push_back(a * d);
	cnd.push_back(b * c);
	cnd.push_back(b * d);
	sort(cnd.begin(), cnd.end());
	cout << cnd.back() << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define br cout << endl ;
#define all(x) (x).begin() ,(x).end()
#define rall(x) (x).rbegin() ,(x).rend()
#define pb push_back
const int MOD = 1000* 1000 * 1000 + 7;
const int MAXN = 1000*1000 + 10 ; 
using namespace std;


int main() {
	int  k ;
	cin >> k ;
	vector<ll>q ;
	for(int i = 1; i < 10 ; ++i)
		q.pb(i) ;
	for( int i = 0 ; i < min((int)q.size(), k ) ; ++i )
	{
		ll top = q[i] % 10 ;
		for(ll j = max (0ll , top-1) ; j <= min(9ll,top+1);++j)
		{	ll newNum = q[i]*10+j; 
			q.pb(newNum);
		} 
		
	}
	--k;
	cout << q[k], br  
 	
return 0 ; 
}		



Measured memory_bytes: 6128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int d1[4] = { 1,0,-1,0 };
int d2[4] = { 0,1,0,-1 };

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;
		int cnt = 0;
		for (int i = 2; i < 46; i++) {
			int x = i * (i - 1) / 2;
			if ((n - x) % i == 0 && n > x) {
				cnt++;
				//cout << i << "*x+" << x << endl;
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    string s;
    cin >> s;
    ll n = s.size();
    for(ll i = 0; i < n; i++)
    {
        for(ll j = i+1; j < n; j++)
        {
            string ss;
            for(ll k = 0; k <= i; k++) ss += s[k];
            for(ll k = j; k < n; k++) ss += s[k];
            if(ss == "keyence") ANS("YES"); //cout << ss << " ";
        }
    }
    ANS("NO");
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

//0もBの倍数では!？

int main(){
  ll N;
  cin >>N;
  ll a[100100]={0},b[100100]={0};
  ll res=0,ans=0;
  rep(i,N)cin >> a[i] >> b[i];
  rep(i,N){
    a[N-1-i]+=ans;
    if(a[N-1-i]==0){
      ans+=0;
    }else{
      res=(a[N-1-i]-1)/b[N-1-i]+1;
      ans+=res*b[N-1-i]-a[N-1-i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int head,leg,frog,crane;
	cin>>head>>leg;
	if(!(head*4>=leg&&(head*4-leg)%2==0))
	{
		cout<<"No"<<endl;
		return 0;
	}
	else
	{
		crane=(head*4-leg)/2;
		frog=head-crane;
		if(crane*2+frog*4==leg&&crane+frog==head&&frog>=0&&crane>=0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}


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

int main()
{
    string S;

    cin >> S;

    bool MM1, MM2;

    if ((S[0] == '0') && (S[1] != '0'))
    {
        MM1 = true;
    }
    else if ((S[0] == '1') && ((S[1] == '0') || (S[1] == '1') || (S[1] == '2')))
    {
        MM1 = true;
    }
    else
    {
        MM1 = false;
    }

    if (S[2] == '0' && (S[3] != '0'))
    {
        MM2 = true;
    }
    else if ((S[2] == '1') && ((S[3] == '0') || (S[3] == '1') || (S[3] == '2')))
    {
        MM2 = true;
    }
    else
    {
        MM2 = false;
    }

    string outstring;

    if ((MM1 == false) && (MM2 == true))
    {
        cout << "YYMM" << endl;
    }
    else if ((MM1 == true) && (MM2 == false))
    {
        cout << "MMYY" << endl;
    }
    else if ((MM1 == true) && (MM2 == true))
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if ((MM1 == false) && (MM2 == false))
    {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt(), y = sc.nextInt();
        sc.close();
        if (x * 2 <= y && y <= x * 4 && y % 2 == 0) return "Yes";
        return "No";
    }
}

Measured memory_bytes: 27056