akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second

int main()
{
	ios_base::sync_with_stdio(0);
	int k;
	cin >> k;
	int n; cin >> n; vector<int> a(2 * n);

	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i + n] = a[i] + k;
	}
	int ans = 1000 * 1000 * 1000;
	for(int i = 0; i < n; i++)
		ans = min(a[i + n - 1] - a[i] , ans);
	cout << ans;
	
}


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

using namespace std;
using ll = long long;

int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (2*c <= a+b) {
        cout << 2 * min(x, y) * c + max((ll)0, (x - y)) * min(2*c, a) + max((ll)0, (y - x)) * min(2*c, b);
    } else {
        cout << x * a + y * b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

std::string takahashi_kun(int N, int M)
{
    if (N == M)
        return "Yes";
    return "No";
}

int main()
{
    int N = 0;
    int M = 0;
    std::cin >> N >> M;
    std::cout << takahashi_kun(N, M) << std::endl;
    return 0;
}


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

void  util(vector<int> adj[],vector<int> &dp,vector<bool> & visited,int x,int n)
{
    
    stack<int> st;
    st.push(x);
    visited[x]=true;
    
    
    while(st.empty()==false)
    {
        x=st.top();
        int i;
        for( i=0;i<adj[x].size();i++)
        {
            int a=adj[x][i];
            if(visited[a]==false)
            {
                visited[a]=true;
                st.push(a);
                break;
            }
            else if(visited[a]==true)
            dp[x]=max(dp[x],dp[a]+1);
        }
        
        if(i==adj[x].size())
        {
            int k=st.top();
            st.pop();
            if(st.empty()==false)
            dp[st.top()]=max(dp[st.top()],dp[k]+1);
            
        }
        
    }
    
}

int main() {
        int n;
        cin>>n;
        int m;
        cin>>m;
        vector<int> adj[n+1];
        int a;int b;
        for(int i=0;i<m;i++)
        {
            cin>>a>>b;
            adj[a].push_back(b);
            
        }
        
      vector<bool> visited(n+1,false);
      vector<int> dp(n+1,0);
      for(int i=1;i<=n;i++)
      {
          if(visited[i]==false)
          util(adj,dp,visited,i,n);
      }
      
      int ans=0;
      for(int i=0;i<=n;i++)
      ans=max(ans,dp[i]);
      
      
      cout<<ans;
        
	return 0;
}

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

string s;
int f = -1;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> s;
	for (int i = 1; i < s.size(); i++) 
		if(s[i] != s[i - 1]) 
			if(f == -1)
				f = max((int)s.size() - i, i);
			else
				f = min(f, max((int)s.size() - i, i));
	if(f == -1)
		cout << (int)s.size();
	else
		cout << f; 
}



Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int N,x=0,max=0,i;
	char S;
	cin >> N;
	for(i=0;i<N;i++)
	{
		cin >> S;
		switch(S)
		{
			case 'I':
				x++;
				if(x>max) max=x;
				break;
			case 'D':
				x--;
				if(x>max) max=x;
				break;
		}
	}
	cout << max << endl;
	return 0;
}

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

factors n = fsub n (2:[3,5..])
  where
    fsub 1 _ = []
    fsub k pa@(p:ps)
      | r==0 = p : fsub q pa
      | k < p*p = [k]
      | otherwise = fsub k ps
      where
        (q, r) = divMod k p

divisors = dsub . group . factors
  where
    dsub [] = [1]
    dsub (d:ds) = (*) <$> (1:(zipWith (flip (^)) [1..] d)) <*> dsub ds

f [n, m] = div m $ minimum $ filter (>=n) $ divisors m

main = map read . words <$> getLine >>= print . f

Measured memory_bytes: 1148
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b>=c)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations


n, k = list(map(int, input().split()))
a = list(range(n + 1))
ans = 0
for i in range(k, n + 2):
    mx = (n - i + 1 + n) * i // 2;
    mn = (0 + i - 1) * i // 2
    ans += mx - mn + 1
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 16780
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register int
#define db double
#define in inline
namespace fast_io
{
    char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
    in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
    in ll read()
    {
        ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
        x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
    }
    in db gf() {re a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
    in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
    in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
    in void flush() {if(C>1<<22) ot();}
    template <typename T>
    in void write(T x,char t)
    {
        re y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
        if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
    }
    in void write(char *s) {re l=strlen(s);for(re i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=4e3+5,p=924844033;
int n,k,tot,ans,a[N],f[N][N][2],g[N],fac[N];
in int add(re a,re b) {return a+b>=p?a+b-p:a+b;}
in int dec(re a,re b) {return a-b<0?a-b+p:a-b;}
in int mul(re a,re b) {return (ll)a*b%p;}
int main()
{
	n=read();k=read();fac[0]=1;for(re i=1;i<=n;i++) fac[i]=mul(fac[i-1],i);
	for(re i=1;i<=k;i++) for(re t=1;t<=2;t++) for(re j=i;j<=n;j+=k) a[++tot]=j;
	f[1][0][0]=1;
	for(re i=2;i<=tot;i++) for(re j=0,mn=min(n,i/2);j<=mn;j++)
	f[i][j][0]=add(f[i-1][j][0],f[i-1][j][1]),f[i][j][1]=(j&&a[i]-a[i-1]==k)*f[i-1][j-1][0];
	for(re i=0,j;i<=n;i++)
	{
		g[i]=add(f[tot][i][0],f[tot][i][1]);
		j=mul(g[i],fac[n-i]);ans=(i&1)?dec(ans,j):add(ans,j);
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 125440
<?php
[$N] = ints();
$A = ints();
$count = 0;
foreach($A as $i => $a){
    $count+=$map[$i-$a]??0;
    $num = $a+$i;
    if(!isset($map[$num]))$map[$num] = 0;
    $map[$num]++;
}
echo $count;

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 40804
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define bk back()
#define pb push_back

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(x,a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

template<class T> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0;
}
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0;
}

// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
    // cin.exceptions(cin.failbit);
    // throws exception when do smth illegal
    // ex. try to read letter into int
    if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

ll freq[MX];

int32_t main() {

    setIO();
    
    string S; cin >> S;

    ll p = 1, sum = 0, res = 0; freq[0]++;
    R0F(i,sz(S)) { 
        int cur = S[i]-'0';
        sum = (sum+(cur*p))%2019;
        p = (p*10)%2019; freq[sum]++;
    }

    F0R(i,2020) {
        if (freq[i] >= 2) res += freq[i]*(freq[i]-1)/2;
    }

    cout << res << "\n";

}


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

using namespace std;

typedef long long int64;

int N;
int64 v[40], w[40], W, ret;

void dfs(int idx, int sz, int64 vv, int64 ww, vector< pair< int64, int64 > > &kk)
{
  if(ww > W) return;
  if(idx == sz) {
    kk.emplace_back(ww, vv);
    return;
  }
  dfs(idx + 1, sz, vv + v[idx], ww + w[idx], kk);
  dfs(idx + 1, sz, vv, ww, kk);
}

int main()
{
  cin >> N >> W;
  for(int i = 0; i < N; i++) cin >> v[i] >> w[i];

  vector< pair< int64, int64 > > a, b;
  dfs(0, N >> 1, 0, 0, a);
  dfs(N >> 1, N, 0, 0, b);
  sort(begin(b), end(b));

  for(int i = 1; i < b.size(); i++) {
    b[i].second = max(b[i].second, b[i - 1].second);
  }

  for(auto &ss : a) {
    auto get = lower_bound(begin(b), end(b), make_pair(W - ss.first + 1, 0LL));
    if(get != begin(b)) {
      --get;
      if(ss.first + get->first > W) continue;
      ret = max(ret, ss.second + get->second);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 43652
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, H: int, W: int):
    print((N-H+1)*(N-W+1))
    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
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(N, H, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _overload(_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(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
double n, r, x[100], y[100], P = acos(-1);
main(){
	cin>>n;
	rep(i, n) cin>>x[i]>>y[i];
	rep(i, n){
        vector<double> d;
        rep(j,n) if(i!=j) d.push_back(atan2(y[j]-y[i], x[j]-x[i]));
		sort(begin(d),end(d));
		r=d[0]-d[d.size()-1]+P;
		rep(j, 1, d.size()) r=max(r,d[j]-d[j-1]-P);
        cout<<max(0.,r/2./P)<<'\n';
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <cstdio>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
P projection(const L& l, const P& p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
P reflection(const L& l, const P& p) {
  return p + 2.0*(projection(l, p) -p);
}

int main(){
    double x1,y1,x2,y2,xq,yq;
    cout << fixed;
    cout << setprecision(6);
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF){
        P ans = reflection(L(P(x1, y1), P(x2, y2)), P(xq, yq));
        cout << ans.X << " " << ans.Y << endl;
    }
    return 0;
}



Measured memory_bytes: 3332
#include <iostream>

using namespace std;

int main() {
  long long mod = 1000000007;
  int n, m;
  cin >> n >> m;
  long long a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    (a += x * ((i << 1) - n + 1) % mod) %= mod;
  }
  for (int i = 0; i < m; i++) {
    long long y;
    cin >> y;
    (b += y * ((i << 1) - m + 1) % mod) %= mod;
  }
  cout << (a * b) % mod << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>
 
#define N 300005
#define M 8000005
 
#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)
 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
const double pi=acos(-1.0);
 
int i,j,m,n,p,k,id[N],x[N],y[N],tree[N],flag,flag2,b[N],f[N];
 
int cmp(int a,int b)
{
		if (x[a]!=x[b])
		return x[a]<x[b];
		return y[a]<y[b];
}
 
int lowbit(int x)
{
		return x&-x;
}
 
int ask(int x)
{
		int s=-(int)1e9;
		for (;x;x-=lowbit(x)) s=max(s,tree[x]);
		return s;
}
 
void ins(int x,int y)
{
		for (;x<=b[0];x+=lowbit(x)) tree[x]=max(tree[x],y);
}
 
int Get(int x)
{
		return lower_bound(b+1,b+b[0]+1,x)-b;
}
 
int main()
{
		scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
		scanf("%d",&n); ++n; 
		if (x[0]>=x[1]) swap(x[1],x[0]),swap(y[0],y[1]);
		if (y[0]==y[1]) flag=1,swap(x[0],y[0]),swap(x[1],y[1]);
		if (y[0]>y[1]) flag2=1,y[0]=n-y[0],y[1]=n-y[1];
		for (i=2;i<=n;++i)
		{
				scanf("%d%d",&x[i],&y[i]);
				if (flag)swap(x[i],y[i]);
				if (flag2) y[i]=n-y[i];
		}
		for (i=0;i<=n;++i) id[i]=i,b[++m]=y[i];
		sort(b+1,b+m+1); b[0]=unique(b+1,b+m+1)-(b+1);
		sort(id,id+n+1,cmp);
		for (i=1;i<=b[0];++i) tree[i]=-(int)1e9;
		for (i=0;i<=n;++i) f[i]=-(int)1e9;
		f[0]=0;
		for (i=0;i<=n;++i)
		{
				int t=id[i];
				if (y[0]<y[1]) f[t]=max(f[t],ask(Get(y[t]))+1);
				f[0]=0;
				ins(Get(y[t]),f[t]);
		}
		double tt=100.*(x[1]-x[0]+y[1]-y[0])+pi*5*(f[1]-1)-2*10*(f[1]-1);
		if ((f[1]-1)==(x[1]-x[0]+1)||(f[1]-1)==(y[1]-y[0]+1)) tt+=(2-pi/2)*10+(pi-2)*10;
		printf("%.15lf\n",tt);
}

Measured memory_bytes: 6400
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
int A[10];
int ans = 0;

void func(int depth, int a)
{
	if (depth == N)
	{
		if (a % 2 == 0)
		{
			ans++;
		}
		return;
	}

	for (int i = -1; i <= 1; i++)
	{
		int prev = a;
		a *= A[depth] + i;
		func(depth + 1, a);
		a = prev;
	}
}

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	func(0, 1);

	cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int countBits(int in){
  int res=0;
  rep(i,10){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

int main() {
  int n,m;cin>>n>>m;
  int ans=0;
  vector<int> A(m,0);
  rep(i,m){
    int k;cin>>k;
    int a=0;
    rep(j,k){
      int s;cin>>s;
      a|=0x01<<(s-1);
    }
    A[i]=a;
  }
  vector<int> P(m);
  rep(i,m){
    cin>>P[i];
  }
  int cnt=pow(2,n);
  rep(i,cnt){
    bool isSwOn=true;
    rep(j,m){
      int ons=i&A[j];
      int onbits=countBits(ons);
      if(onbits%2!=P[j]){
        isSwOn=false;
        break;
      }
    }
    if(isSwOn){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long x;
  cin>>x;
  
  long c=100;
  for(int i=1;i<5000;i++){
    c*=1.01;
    if(c>=x){
      cout<<i<<endl;
      break;
  }
}
}
  

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, maxi;
int aoki[100005], lo[100005], up[100005];
long long score[100005];
bool higher[100005];

long long require;
long long ans, ans1, ans2;

vector<pair<long long, int> > chase;

int main(){
	scanf("%d %d", &n, &maxi);
	for(int i = 1; i <= n; i++){
		scanf("%d %d %d", &aoki[i], &lo[i], &up[i]);
		require += 1LL * aoki[i] * lo[i];
		score[i] = 1LL * aoki[i] * lo[i] + 1LL * (maxi - aoki[i]) * up[i];
		chase.push_back({-score[i], i});
	}
	sort(chase.begin(), chase.end());
	for(auto choice: chase){
		long long delta = choice.first;
		int id = choice.second;
		if(require + delta <= 0){
			// two scenarios
			// scenario 1: pick all "higher", one partial from "lower" ones
			int opt = maxi;
			for(int i = 1; i <= n; i++){
				if(!higher[i]){
					// see if it can make up the difference of delta
					if(score[i] < require){
						continue;
					}else if(1LL * aoki[i] * lo[i] >= require){
						opt = min(opt, (int)ceil((require + .0) / lo[i]));
					}else{
						opt = min(opt, aoki[i] + (int)ceil((require - 1.0 * aoki[i] * lo[i]) / up[i]));
					}
				}
			}
			ans1 = ans + opt;
			// scenario 2: pick all "higher" and this, then make one "higher" partial
			higher[id] = true;
			require += delta;
			opt = maxi;
			for(int i = 1; i <= n; i++){
				if(higher[i]){
					long long target = require + score[i]; // should be positive
					if(1LL * aoki[i] * lo[i] >= target){
						opt = min(opt, (int)ceil((target + .0) / lo[i]));
					}else{
						opt = min(opt, aoki[i] + (int)ceil((target - 1.0 * aoki[i] * lo[i]) / up[i]));
					}
				}
			}
			ans2 = ans + opt;
			printf("%lld\n", min(ans1, ans2));
			return 0;
		}
		higher[id] = true;
		require += delta;
		ans += maxi;
	}
	return 0;
}

Measured memory_bytes: 3952
"""ABC091 2D Plane 2N Points diff:
"""

N = int(input())

ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(N)]

ans_x = 0
cd.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1], reverse=True)
ab_used = [0]*N
for i, (c, d) in enumerate(cd):
    for j, (a, b) in enumerate(ab):
        if not ab_used[j] and a < c and b < d:
            ab_used[j] = 1
            ans_x += 1
            break

ans_y = 0
cd.sort(key=lambda x: x[1])
ab.sort(key=lambda x: x[0], reverse=True)
ab_used = [0]*N
for i, (c, d) in enumerate(cd):
    for j, (a, b) in enumerate(ab):
        if not ab_used[j] and a < c and b < d:
            ab_used[j] = 1
            ans_y += 1
            break

print(max(ans_x, ans_y))

Measured memory_bytes: 67660
import itertools

N = int(input())
P = "".join(input().split())
Q = "".join(input().split())
L = []
for p in itertools.permutations(map(str, range(1,N+1))):
    L.append("".join(p))
L.sort()
p = -1
q = -1
i = 0
for elem in L:
    if P == elem:
        p = i
    if Q == elem:
        q = i
    i+=1
ans = abs(q-p)
print(ans)


Measured memory_bytes: 6040
N = int(input())
h = list(map(int, input().split()))

S = [0] * N
S[0] = 0
S[1] = abs(h[1] - h[0])

for i in range(2, N):
    jump1 = S[i - 1] + abs(h[i] - h[i - 1])
    jump2 = S[i - 2] + abs(h[i] - h[i - 2])
    S[i] = min(jump1, jump2)

# print(S)
print(S[N - 1])


Measured memory_bytes: 20584
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	int x[4], y[4];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	x[2] = x[1] - y[1] + y[0];
	y[2] = y[1] - x[0] + x[1];
	x[3] = x[2] - y[2] + y[1];
	y[3] = y[2] - x[1] + x[2];
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;





	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input, input_cnt, prime_cnt, cnt;
	int output[30];
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
	{
		if(is_prime1(cnt))
		{
			prime[prime_cnt] = cnt;
			prime_cnt++;
		}
	}
	
	/*Get, calculate input then save in output[]*/
	input_cnt = 0;
	while(scanf("%d", &input) != EOF)
	{
		prime_cnt = 0;
		if(input >= 2)
		{
			prime_cnt++;
		}
		for(cnt = 3; cnt <= input; cnt += 2)
		{
			if(is_prime2(cnt))
			{
				prime_cnt++;
			}
		}
		output[input_cnt] = prime_cnt;
		input_cnt++;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_cnt; cnt++)
	{
		printf("%d\n", output[cnt]);
	}
	
    return 0;
}

/*Test prime directly*/
int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1)
	{
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7)
	{
		return 1;
	}
	else if((prime1_input % 2) == 0)
	{
		return 0;
	}

	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
		if(prime1_input % prime1_cnt == 0)
			return 0;
	return 1;
}

/*Test prime with prime table*/
int is_prime2(int prime2_input)
{
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++){
		if(prime[prime2_cnt] > sqrt(prime2_input))
			break;
		if(prime2_input % prime[prime2_cnt] == 0)
			return 0;
	}
	return 1;
}

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

string s;
int Q;

int main()
{
	cin >> s >> Q;
	bool flag = false;
	int x, y;
	char c;
	while(Q--){
		cin >> x;
		if(x == 1){
			flag = !flag;
		}else{
			cin >> y >> c;
			if(y == 1){
				if(!flag) s.insert(s.begin(),c);
				else s += c;
			}else{
				if(!flag) s += c;
				else s.insert(s.begin(),c);
			}
		}
	}
	if(flag) reverse(s.begin(),s.end());
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 900
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(sc.hasNext()){
			String a = sc.nextLine();
			String b = yms(a);
			if(a.equals(b)) count++;
		}
		System.out.println(count);
	}
	
	static String yms(String str){
		int length = str.length();
		char[] code = str.toCharArray();
		
		for(int i = 0; i < length/2; i++){
			char temp = code[i];
			code[i] = code[length-1-i];
			code[length-1-i] = temp;
		}
		String string = "";
		for(int i = 0; i < length; i++){
			string += code[i];
		}
		return string;
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
   
  int Gokei=0;
  for(int i=0; i<N; i++){
    for(int j=0+i; j<N; j++){
      if(i != j){
        Gokei = Gokei + d.at(i) * d.at(j);
      }
    }
  }
 
  cout << Gokei << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
 
using namespace std;
 
#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)

const int N = 2e5 + 10;

int road[N];
int rail[N];
 
map<int, int> mp[N];
 
int par(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
 
void sset(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}
 
int main()
{
  int n;
  cin>>n;
  repn(i, 0, n) road[i] = rail[i] = i;
  int k, l;
  cin>>k>>l;
  while(k--)
  {
    int a, b;
    cin>>a>>b;
    int spa = par(a, road);
    int spb = par(b, road);
    sset(b, spa, road);
  }
  while(l--)
  {
    int a, b;
    cin>>a>>b;
    int spa = par(a, rail);
    int spb = par(b, rail);
    sset(b, spa, rail);
  }
  repn(i, 1, n)
  {
    int sproad = par(i, road);
    int sprail = par(i, rail);
    mp[sproad][sprail]++;
  }
  repn(i, 1, n)
  {
    int sproad = par(i, road);
    int sprail = par(i, rail);
    cout<<mp[sproad][sprail]<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 20096
import sys
for s in sys.stdin:
    a,b,c,d,e,f=map(int,s.split())
    x=c*e-b*f
    y=a*f-c*d
    z=a*e-b*d
    def f(x,z):
        if x==0: return 0
        else: return 1.0*x/z
    print "%.3f %.3f" %(f(x,z),f(y,z))

Measured memory_bytes: 4232
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-05-17 19:57
# @url:
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    if n%10 in (2,4,5,7,9):
        print ("hon")
    elif n%10 in (0,1,6,8):
        print ("pon")
    else:
        print ("bon")
if __name__ == "__main__":
    main()

Measured memory_bytes: 68464
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		cout<<n*n*n<<endl;
	}
	return 0;
}

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

int main(){
  int N,x ;
  cin >> N >> x;
  vector<int> list(N);
  int ans=0 ;
  for (int i=0; i<N; i++){
    cin >> list.at(i);
  }
  sort(list.begin(),list.end());
  for (int j=0; j<N; j++){
    if(j !=N-1){
      if(x>=list[j]){
        x -= list[j];
        ans ++;
      }
      else break;
    }
    else{
      if(x==list[j]) ans ++;
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <algorithm>
#include <list>
#include <string.h>
#include <unordered_map>
#include <ctype.h>
#include <queue>
#include <numeric>
#include <vector>
#include <iomanip>
#include <cstdlib>
#include <stack>
#include <ctime>
#define  lld  long long int
#define rep(i,start,end) for(lld i = start;i<end;i++)
#define newline cout << endl
#define fastio ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define in insert
#define mp make_pair
#define se second
#define fi first
#define starttime chrono::time_point<chrono::system_clock> start, end; start = chrono::system_clock::now()
#define showtime end = chrono::system_clock::now();  chrono::duration<double> elapsed_seconds = end - start; time_t end_time = chrono::system_clock::to_time_t(end); cout << "elapsed time: " << elapsed_seconds.count() << "s\n"
#define INF 1e17
lld MOD =  (lld)(1e19+7);
#define mh make heap
#define ph push_heap
#define poph pop_heap
#define openf   freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
using namespace std;
lld add(long long a, long long b){return ((a%MOD)+(b%MOD))%MOD;}
lld mul(long long a, long long b){return ((a%MOD)*(b%MOD))%MOD;}
lld sub(long long a, long long b){lld ans = ((a%MOD-b%MOD))%MOD; if(ans<0) ans += MOD; return ans;}
lld modInverse(lld a ){   lld m = MOD,m0 = m, y = 0, x = 1;  if (m == 1) return 0;   while (a > 1) {  lld q = a / m, t = m;  m = a % m, a = t, t = y;          y = x - q * y, x = t;   } if (x < 0)  x += m0; return x; } 
lld gcd(lld a, lld b){if (b == 0) return a; return gcd(b, a % b);}
void MAIN(lld i,lld t);
int get(){lld t;cin>>t; ; return t;}
template<class T> int logd(T name){cout<<name<<endl; return 0;}
void test(int t) { for(lld i = 0;i<t;i++){MAIN(i,t); cout <<endl;} }
lld power(lld x, lld y) { lld res = 1; x = x%MOD; if(x==0) return 0;   while (y > 0) {   if (y & 1)      res = (res*x)%MOD; y = y>>1; x = (x*x)%MOD;} return res; }
#define all(v) (v).begin(),(v).end()
lld popcount(lld x){return __builtin_popcountll(x);}
lld lcm(lld a,lld b){ return (a*b)/gcd(a,b);}

void MAIN(lld current_test_case,lld total_test_cases){
    string s,t;
    cin >> s >> t;
    lld count = 0;
    for(int i = 0;i<s.size();i++)
        if(s[i]!=t[i]) count++;
    cout << count << endl;
}   
int main(){  
    fastio;
    #ifndef ONLINE_JUDGE 
     openf
    #endif
    test(1);
    return 0;
}



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

int main(void)
{
    string s;
    cin >> s;
    map<char, int> aMap;
    for (int i = 0; i < 4; i++)
    {
        auto itr = aMap.find(s[i]);
        if (itr != aMap.end())
        {
            aMap[s[i]] = aMap[s[i]] + 1;
        }
        else
        {
            aMap[s[i]] = 1;
        }
    }
    bool flag = true;
    for (int i = 0; i < 4; i++)
    {
        if(aMap[s[i]]!=2)
        {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes":"No") << endl;
}

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

vector<string> words;
vector<int> scores;

void addWord(string word, int value) {
  uint i;
  for(i = 0; i < words.size(); i++) {
    if(words.at(i) == word) {
      scores.at(i) += value;
      break;
    }
  }
  if(i == words.size()) {
    words.push_back(word);
    scores.push_back(value);
  }
}

int main() {
  int n, m;
  string word;
  cin >> n;

  for(int i = 0; i < n; i++) {
    cin >> word;
    addWord(word, 1);
  }

  cin >> m;
  for(int i = 0; i < m; i++) {
    cin >> word;
    addWord(word, -1);
  }

  int maxVal = 0;
  for(uint i = 0; i < scores.size(); i++) {
    if(scores.at(i) > maxVal) {
      maxVal = scores.at(i);
    }
  }

  cout << maxVal << endl;
  return 0;
}
  


Measured memory_bytes: 256
import itertools

P1=[p*(p+1)*(p+2)/6 for p in range(1,181)]
P2=[p for p in P1 if p%2]

maxnum=1000000

A1=[5 for x in range(maxnum+1)]
A2=[37 for x in range(maxnum+1)]

for X in [[P1,A1],[P2,A2]]:
    P=X[0]
    A=X[1]
    mx=A[0]
    tmp=P
    bk=0
    cnt=2
    for p in tmp:
        if p<maxnum:
            A[p]=1
            bk+=1
    while cnt<mx:
        tmp2=[]
        for t in tmp:
            for p in P:
                if t+p > maxnum:    break
                if A[t+p]>cnt:
                    A[t+p]=cnt
                    bk+=1
                    tmp2.append(t+p)
        tmp=tmp2[:]
        cnt+=1
while(1):
    n=int(raw_input())
    if n==0: break
    print A1[n], A2[n]



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

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    sort(all(a));
    if(a.back()-a.front()>=2){
        cout<<"No"<<endl;
        return 0;
    }
    if(a.front()==a.back()){
        cout<<((a.front()==n-1 or n>=a.front()*2) ? "Yes":"No")<<endl;
        return 0;
    }
    int x,y;
    rep(i,n-1){
        if(a.at(i)!=a.at(i+1)){
            x=i+1; y=n-x;
        }
    }
    cout<<((a.front()>=x and a.front()<=x-1+y/2) ? "Yes":"No")<<endl;
}

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

using namespace std;

int lg, N, M, X, Y, Z, realVal[200009], mp1[100009], mp2[100009], cnt[2][200009];
long long SA, aib[2][200009];
pair < int, int > P[100009];
vector < pair < int, int > > nrm;

void Normalize ()
{
    for (int i=1; i<=N; i++)
        nrm.push_back ({P[i].second - P[i].first, i}), nrm.push_back ({P[i].second, -i});
    sort (nrm.begin (), nrm.end ()), reverse (nrm.begin (), nrm.end ()), M = nrm.size ();
    for (int i=0; i<nrm.size (); i++)
    {
        if (nrm[i].second > 0) mp1[nrm[i].second] = i + 1;
        else mp2[-nrm[i].second] = i + 1;
        realVal[i + 1] = nrm[i].first;
    }
}

void U (int lin, int pos, int sg)
{
    int val = realVal[pos] * sg;
    while (pos <= M)
        cnt[lin][pos] += sg,
        aib[lin][pos] += val,
        pos += pos - (pos & (pos - 1));
}

long long sumQ (int lin, int atMost)
{
    int pos = 0;
    long long ans = 0;
    for (int i=lg; i>=0; i--)
        if (pos + (1 << i) <= M && cnt[lin][pos + (1 << i)] <= atMost)
            pos += 1 << i, atMost -= cnt[lin][pos], ans += aib[lin][pos];
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &X, &Y, &Z), N = X + Y + Z;
for (int i=1; i<=N; i++)
{
    int ai, bi, ci;
    scanf ("%d %d %d", &ai, &bi, &ci), SA += ai;
    bi -= ai, ci -= ai;
    P[i] = {bi, ci};
}
sort (P + 1, P + N + 1), reverse (P + 1, P + N + 1);
Normalize ();
while ((1 << (lg + 1)) <= M) lg ++;
long long SB = 0, best = 0;
for (int i=1; i<=N; i++)
    U (1, mp2[i], +1);
/*printf ("%lld + \n", SA);
for (int i=1; i<=N; i++)
    printf ("(%d, %d)\n", P[i].first, P[i].second);*/
for (int i=1; i<=Y + Z; i++)
{
    SB += P[i].first, U (0, mp1[i], +1);
    U (1, mp2[i], -1);
    if (i >= Y)
    {
        long long curr = SA + SB + sumQ (0, i - Y) + sumQ (1, Z - (i - Y));
        if (curr > best)
            best = curr;//, printf ("after %d -> %lld\n", i, best);
    }
}
printf ("%lld\n", best);
return 0;
}


Measured memory_bytes: 8944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  string s;

  cin >> s;

  int i = 0;
  while(i < s.size()) {
    int rc = 0;
    int lc = 0;
    int rr, ll;
    while(s[i] == 'R') {
      i++;
      rc++;
    }
    rr = i-1;
    ll = i;
    while(i < s.size() && s[i] == 'L') {
      i++;
      lc++;
    }
    rep(j, rc-1) {
      cout << 0 << endl;
    }
    cout << (lc/2 + rc - rc/2) << endl;
    cout << (rc/2 + lc - lc/2) << endl;
    rep(j, lc-1) {
      cout << 0 << endl;
    }
  } 
}


Measured memory_bytes: 704
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

int main(){
    string s, t; cin >> s >> t;
    string s_ = s, t_ = t;
    reverse(all(s)); reverse(all(t));

    if(s == t_ && t == s_) cout << "YES" << ln;
    else cout << "NO" << ln;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
long A[100100];
long lngst=0;

long abs(long a,long b){
    if(b>a) return b-a;
    else return a-b;
}

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>A[i];
        if(i==0) lngst+=abs(0,A[i]);
        else lngst+=abs(A[i],A[i-1]);
    }
    lngst+=abs(0,A[N-1]);

    for(int i=0;i<N;++i){
        if(i==0){
            if(A[0]*(A[1]-A[0])>=0) cout<<lngst<<endl;
            else if(A[1]*(A[0]-A[1])>=0) cout<<lngst-2*abs(A[1],A[0])<<endl;
            else if(A[i]*A[i+1]<=0) cout<<lngst-2*abs(0,A[0])<<endl;
        }
        else{
            if((A[i]-A[i-1])*(A[i+1]-A[i])>=0){
                cout<<lngst<<endl;
            }
            else if((A[i+1]-A[i-1])*(A[i]-A[i+1])>=0){
                cout<<lngst-2*abs(A[i],A[i+1])<<endl;
            }
            else if((A[i-1]-A[i])*(A[i+1]-A[i-1])>=0){
                cout<<lngst-2*abs(A[i-1],A[i])<<endl;
            }
        }
    }
}

Measured memory_bytes: 2048
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

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

using namespace std;

int main() {
    int r, g, p;
    cin >> r >> g;

    p = 2*g - r;

    cout << p << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  string s;
  //string s[200000];
  cin >> s;
  //string st[200000];
  //char ch[200000];
  int sum=0;
  int n=s.length();
  rep(i,n){
    //cout << sum << endl;
    //cout << s[i] << endl;
    //const char* cstr = s[i];
    //string str = cstr;
    //char ch=s[i];
    //string str = string(ch);
    sum += (int(s[i])-48);
    //sum += stoi(str);
    //sum += s[i];
    //sum += stoi(s);
  }
  //cout << sum << endl;
  //cout << n << endl;
  if(sum%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3716
#include<iostream>
#include<map>
#include<queue>

using namespace std;

const int NOT=-1;
int maps[51][51];
int x,y;
int tx,ty;
int kx,ky;
int ans=101;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int sai[52][52][52][52];
typedef pair<int,int> P;
typedef pair<P,P> PP;

void bfs(){
	queue<PP> pp;
	int a,b,c,d;
	for(a=0;a<=50;a++){
		for(b=0;b<=50;b++){
			for(c=0;c<=50;c++){
				for(d=0;d<=50;d++){
					sai[a][b][c][d]=NOT;
				}
			}
		}
	}
	pp.push(PP(P(tx,ty),P(kx,ky)));
	sai[tx][ty][kx][ky]=0;
	while(pp.size()){
		PP p=pp.front();pp.pop();
		if(p.first.first==p.second.first && p.first.second==p.second.second){
			ans=sai[p.first.first][p.first.second][p.second.first][p.second.second];
			break;
		}
		if(sai[p.first.first][p.first.second][p.second.first][p.second.second]<100){
			for(a=0;a<4;a++){
				int ntx,nty,nkx=p.second.first-dx[a],nky=p.second.second-dy[a];
				
				if(maps[p.first.first+dx[a]][p.first.second+dy[a]]==0 && p.first.first+dx[a]>=1 && p.first.first+dx[a]<=x && p.first.second+dy[a]>=1 && p.first.second+dy[a]<=y){
					ntx=p.first.first+dx[a],nty=p.first.second+dy[a];
				}else ntx=p.first.first,nty=p.first.second;

				if(maps[p.second.first-dx[a]][p.second.second-dy[a]]==0 && p.second.first-dx[a]>=1 && p.second.first-dx[a]<=x && p.second.second-dy[a]>=1 && p.second.second-dy[a]<=y){
					nkx=p.second.first-dx[a],nky=p.second.second-dy[a];
				}else nkx=p.second.first,nky=p.second.second;
				
				if(sai[ntx][nty][nkx][nky]==NOT){
					pp.push(PP(P(ntx,nty),P(nkx,nky)));
					sai[ntx][nty][nkx][nky]=sai[p.first.first][p.first.second][p.second.first][p.second.second]+1;
				}
			}
		}
	}
}

int main(void){
	while(1){
		cin >> x >> y;
		if(x==0 && y==0)break;
		cin >> tx >> ty;
		cin >> kx >> ky;
		int a,b;
		ans=101;
		for(a=1;a<=y;a++){
			for(b=1;b<=x;b++){
				cin >> maps[b][a];
			}
		}
		bfs();
		if(ans<=100)cout << ans << endl;else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 28000
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
	ll n; cin >> n;
	ll a[n], b[n];
	for(ll i = 0; i < n; ++i){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	map<ll, pair<ll, ll> > m;
	for(ll i = 0; i < n; ++i) m[b[i]] = pair<ll, ll>(0, 0);
	for(ll i = 0; i < n; ++i) (i & 1 ? m[b[i]].first : m[b[i]].second)++;
	ll ans = 0;
	for(ll i = 0; i < n; ++i){
		if(i & 1){
			if(!m[a[i]].first){
				ans++;
				m[a[i]].second--;
			}else{
				m[a[i]].first--;
			}
		}else{
			if(!m[a[i]].second){
				ans++;
				m[a[i]].first--;
			}else{
				m[a[i]].second--;
			}
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 10112
#include<iostream>
#include<string> 
using namespace std; 
int main(){ 

string a;
 
int ab[26]={}; 

int i; 

while(getline(cin,a)){ 
for(i=0;i<a.size();i++){ 
 if(a[i]>='a'&&a[i]<='z') ab[a[i]-'a']++;
 else if(a[i]>='A'&&a[i]<='Z') ab[a[i]-'A']++;
}



}

for(i=0;i<26;i++){ 
cout << (char)('a'+i) << " : " << ab[i] << endl;
}

return 0;
} 


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> cnt(2, 0);
  rep(i, n) {
    if (s[i] == 'R') cnt[0]++;
    else cnt[1]++;
  }
  cout << (cnt[0] > cnt[1] ? "Yes" : "No") << endl;


  
  return 0;
}

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int>m(N);
  for(int i=0;i<N;i++){
   cin >> m.at(i);
  }
  //total
  int total=0;
  
  for(int i=0;i<N;i++){
    total +=m.at(i);
  }
  
  sort(m.begin(),m.end());
  
  if((X-total)==0){
    cout << N << endl;
  }else{
    cout << ((X-total)/m.at(0))+N << endl;
  }

}

Measured memory_bytes: 256