akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

typedef long long ll;

int main(){
  int n;
  string s;

  cin >> n >> s;

  int q;
  cin >> q;

  while(q-- > 0){
    int k;
    cin >> k;

    ll ans = 0;
    int cntd = 0, cntm = 0;
    ll cntdm = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == 'D'){
        cntd++;
      }else if(s[i] == 'M'){
        cntm++;
        cntdm += cntd;
      }

      if(s[i] == 'C'){
        ans += cntdm;
      }

      if(i >= k-1){
        if(s[i-(k-1)] == 'D'){
          cntdm -= cntm;
          cntd--;
        }else if(s[i-(k-1)] == 'M'){
          cntm--;
        }
      }
    }

    cout << ans << endl;

  }// end of while

  return 0;
}

Measured memory_bytes: 1412
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as C
import Data.Coerce
import Data.Graph
import Data.List

main = sol <$> gett >>= print

gett = unfoldr (runStateT $ (,) <$> geti <*> geti) <$> C.getContents

geti = coerce $ C.readInt . C.dropWhile (<'0') :: StateT C.ByteString Maybe Int

sol ((n,m):es) = length $ filter brdg [0..m-1]
  where
  brdg i = not $ path g u v
    where
    (u,v) = es!!i
    g = buildG (1,n) . concatMap (\(u,v) -> [(u,v),(v,u)]) $ es \\ [(u,v)]

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

vi g[214514];
int c[214514][2];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, a, b;
	string s;
	cin>>n>>m;
	cin>>s;
	REP(i, m){
		cin>>a>>b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
		++c[a][s[b]-'A'];
		++c[b][s[a]-'A'];
	}
	queue<int> q;
	bool v[214514];
	REP(i, n){
		v[i]=true;
	}
	REP(i, n){
		if(!c[i][0] || !c[i][1]){
			q.push(i);
			v[i]=false;
		}
	}
	int cnt=0;
	while(!q.empty()){
		++cnt;
		int i=q.front();
		q.pop();
		REP(j, g[i].size()){
			--c[g[i][j]][s[i]-'A'];
			if(!c[g[i][j]][s[i]-'A'] && v[g[i][j]]){
				q.push(g[i][j]);
				v[g[i][j]]=false;
			}
		}
	}
	cout<<(cnt!=n ? "Yes" : "No")<<'\n';
	return 0;
}


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

#define debug(x) cerr << #x << " : " << x << '\n';

// code //


int main() {
	int n, m, minDiff = INT_MAX;
	string s, t;
	cin >> s >> t;
	
	n = s.size();
	m = t.size();
	
	for(int i = 0; i < n - m + 1; i++) {
		int diff = 0;
		string copy = s.substr(i, m);
		for(int i = 0; i < m; ++i) {
			if(copy[i] != t[i]) diff++;
		}
		minDiff = min(minDiff, diff);
	}
	
	cout << minDiff;
}	


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }
const int MAX_N = 110;
const int MAX_W = 100100;

int main() {
    int N, W;
    cin >> N >> W;
    long long dp[MAX_W] = {0};
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; i++) { cin >> weight[i] >> value[i]; }
    
    for (int i = 0; i < N; i++) {
        for (int w = MAX_W; w >= 0; w--) {
            if (0 <= w-weight[i]) chmax(dp[w], dp[w-weight[i]] + value[i]);
        }
    }
    
    cout << dp[W] << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  int L = (S.at(0) - '0')*10 + (S.at(1) - '0');
  int R = (S.at(2) - '0')*10 + (S.at(3) - '0');
  
  if(1<=L && L<=12){
    if(1<=R && R<=12){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout << "MMYY" << endl;
    }
  }
  else{
    if(1<=R && R<=12){
      cout << "YYMM" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import math

def main():
    n,k=map(int,input().split())
    s = 0
    for i in range(1, n+1):
        c=max(0, math.ceil(math.log(k/i, 2)))
        #print(c)
        s += (1/2)**c
    print(s/n)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <stdio.h>
int main(void){
    int r, c, s, a;
    int i, j;
    int b[101]={0};
    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++){
        s = 0;
        for(j = 0; j < c; j++){
            scanf("%d",&a);
            b[j] += a;
            s += a;
            printf("%d ",a);
        }
        printf("%d\n",s);
    }
    s = 0;
    for(i = 0; i < c; i++){
        s += b[i];
        printf("%d ",b[i]);
    }
    printf("%d\n",s);
    return 0;
}




Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
	int i,a,b,c,w[100],flg;
	flg=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=1;i<=100;i++){
		w[i]=a*i;
		if(w[i]%b==c){
			flg=1;
		}
	}
	if(flg==1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

int main(){
    int k;
    double n,cnt=0;
    cin>>n>>k;
    
    for(int i=1;i<n+1;i++){
        if(i>=k) cnt+=1;
        else{
            int a=i;
            double coin=1;
            while(a<k){
                a*=2;
                coin/=2;
                //cout<<a<<" "<<coin<<"   ";
            }
            cnt+=coin;
            //cout<<cnt<<endl;
        }
    }

    cout<<setprecision(15)<<cnt/n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll d[n];
  map<ll, int> m;
  REP(i, n){
    cin >> d[i];
    m[d[i]]++;
  }
  ll ans = 0;
  REP(i, m.size()){
    if(m[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=gets.to_i
S=gets.chomp
gets
res=1
i=0
f=0
while(i<S.size)
    if S[i]==S[i+1]
        if f==0
            res=6
        elsif f==1
            res*=2
        else 
            res*=3
        end
        f=2
        i+=1
    else
        if f==0
            res=3
        elsif f==1
            res*=2
        else 
            res*=1
        end
        f=1
    end
    i+=1
    res%=1000000007
end
puts res


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

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define y1 asdgh
#define int long long
#define double long double
#define endl '\n'
//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*------------------------------<Debugging Stuff>---------------------------------*/

template<class L, class R> ostream& operator<<(ostream &os, pair<L , R> P) {
      return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R , class M> ostream& operator<<(ostream &os, tuple<L , R , M> P) {
      return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
      os << "{ "; for(auto v : V) os << v << " "; return os << "}";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*------------------------------</Debugging Stuff>--------------------------------*/
const int maxn = (int) 4 * 1e5 + 6;
const double EPS = 1e-9;
const int INF = (int) 1e18 + 7;
const int mod = (int) 1e9 + 7;

signed main(){
      fio;
      int n; cin >> n;
      vector<int> b(n - 1) , a(n);
      for(int &x : b) cin >> x;
      a[0] = b[0] , a[n - 1] = b[n - 2];
      for(int i = 1; i < n - 1; i++){
            a[i] = min(b[i - 1] , b[i]);
      }
      
      cout << accumulate(a.begin() , a.end() , 0LL) << endl;

      return 0;
}

// IMPORTANT -:
// check base cases n = 0 , n = 1
// max / min questions - check for binary search
// difference array might be interesting
// {i , j} --> i * m + j or i + j * n



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

int main()
{
	int i, a, b, m, x, y, c, mn=99999999, arr[1000000], brr[1000000];
	cin>>a>>b>>m;
	for(i=0;i<a;i++)cin>>arr[i];
	for(i=0;i<b;i++)cin>>brr[i];
	for(i=0;i<m;i++){
		cin>>x>>y>>c;
		mn = min(mn, arr[x-1]+brr[y-1]-c);
	}
	sort(arr, arr+a);
	sort(brr, brr+a);
	mn = min(mn, arr[0]+brr[0]);
	cout<<mn<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  int A,B;
  if(N==2)
  {
    cin >> A >> B;
    cout << A+B << endl;
  }
  else
  {
    cout << "Hello World" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String srgs[]) {
		Scanner sc = new Scanner(System.in);
		int n;

		while (sc.hasNext()) {
			n = sc.nextInt();
			String s = "3C";
			String s2 = "0";
			n %= 39;
			n = (n == 0) ? 39 : n;
			s += (0 <= n && n <= 9) ? s2 + Integer.toString(n) : Integer.toString(n);
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define MOD 998244353
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

int main() {

    int n, m;cin >> n >> m;
    /// firstがto secondがcost
    const ll INF = 1001001001;
    struct Edge {ll to; ll cost;};
    vector<Edge> g[n];


    rep(i,m) {
        ll l, r; cin >> l >> r;
        ll c; cin >> c;
        Edge edge1 = {r-1, c};
        g[l-1].push_back(edge1);
    }
    rep(i, n-1) {
        Edge edge = {i, 0};
        g[i+1].push_back(edge);
    }
    priority_queue<P, vector<P>, greater<P>> pq;
    //ll d[n];
    //fill(d, d + n, INF);
    vector<ll> d(n, 1e15);
    d[0] = 0;
    pq.push(P(0, 0));

    while(! pq.empty()){
        P p = pq.top(); pq.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
//            auto e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(P(d[e.to], e.to));
            }
        }
    }

    ll ans = d[n-1];
    if (ans >= 1e15) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 9340
#muri
N = int(input())
T, A = list(map(int,input().strip().split()))
H_list = list(map(int,input().strip().split()))
trueH = (T - A)/0.006
sa = float("inf")

for i in range(0,N):
    num = trueH - H_list[i]
    if abs(num) < sa:
        sa = abs(num)
        ans = i

print(ans+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
  

int main() {

   int n,t,a;
   cin>>n>>t>>a;
   
   int arr[n];
   
   vector<double> v;
   
   for(int i=0;i<n;++i)
      cin>>arr[i];
    
     for(int i=0;i<n;++i)
        v.pb(abs((t-(arr[i]*0.006))-a));
        
       // for(auto it=v.begin();it!=v.end();++it)
        //  cout<<*it<<" ";
      double min1 = 10000000;
      for(auto it=v.begin();it!=v.end();++it)
        min1 = min(min1,*it);
        
       // cout<<min1;
        
        cout<<find(v.begin(),v.end(),min1)-v.begin()+1;
  //   cout<<min_elelment(v.begin(),v.end());
	return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    int x[n];
    rep (i, n) cin >> x[i];

    ll sum = 1e9;
    
    rep (i, 105) {
        ll cnt = 0;
        rep (j, n) cnt += (x[j] - i) * (x[j] - i);
        chmin(sum, cnt);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type Elem struct {
	A, B, C int
}

type Elems []*Elem

func (e Elems) Len() int {
	return len(e)
}

func (e Elems) Less(i, j int) bool {
	return (e[i].A - e[i].B) < (e[j].A - e[j].B)
}

func (e Elems) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a, b := nextInts(n), nextInts(n)
	elems := make(Elems, n)
	sumA, sumB := 0, 0
	for i := 0; i < n; i++ {
		elems[i] = &Elem{a[i], b[i], a[i]}
		sumA, sumB = sumA+a[i], sumB+b[i]
	}
	sort.Sort(elems)

	if sumA < sumB {
		puts(-1)
		return
	}

	// Cを調整
	for inc, dec := 0, n-1; dec >= 0 && inc < n && inc <= dec; {
		dinc, ddec := elems[inc].B-elems[inc].C, elems[dec].C-elems[dec].B
		// puts(dec, elems[dec], ddec, inc, elems[inc], dinc)
		if dinc <= 0 {
			break
		}
		if dinc == ddec {
			elems[inc].C += dinc
			elems[dec].C -= ddec
			dec--
			inc++
		} else if dinc < ddec {
			elems[inc].C += dinc
			elems[dec].C -= dinc
			inc++
		} else {
			elems[inc].C += ddec
			elems[dec].C -= ddec
			dec--
		}
	}

	ans := 0
	for _, e := range elems {
		if e.A != e.C {
			ans++
		}
	}
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 6528
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = deque([])
for i, x in enumerate(p):
    if i == 0:
        p_acc.append((x + 1) / 2)
    else:
        p_acc.append((x + 1) / 2 + p_acc[i - 1])
ans = 0
for i in range(n - k + 1):
    equity = p_acc[k - 1 + i] - p_acc[i - 1] if i != 0 else p_acc[k - 1]
    if equity > ans:
        ans = equity
print(ans)

Measured memory_bytes: 25956
#include<iostream>
#include<string>

using namespace std;

int main()
{
	
	int a,b,c;
	string s;
	cin >> a >> b;
	if((a * b % 2) == 0){
		cout <<"Even" << endl;
	}else{
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= a-i; j++){
      int k = a -  i - j;
      if(i * 10000 + j * 5000 + k * 1000 == b){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = -10**18

for i in range(n):
    tmp_score = 0
    pos = i
    # cycle = 0
    for l in range(k):
        pos = p[pos]-1
        tmp_score += c[pos]
        ans = max(ans,tmp_score)
        # cycle += 1
        if pos == i: break
    q,r = divmod(k,l+1)
    if r == 0 and q > 1:
        r = l+1
        q -= 1
    tmp_score *= q
    ans = max(ans,tmp_score)
    for _ in range(r):
        pos = p[pos]-1
        tmp_score += c[pos]
        ans = max(ans,tmp_score)        
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD =  1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n);
    Vec ans(n);
    ll a = 0;
    rep(i,n){
        int tmp;
        cin>>tmp;
        v[i]=tmp;
        if(i%2==0){
            a += tmp;
        }else{
            a -= tmp;
        }
    }
    ll x = a;
    rep(i,n){
        if(i==0){
            ans[i]=x;
        }else{
            ans[i]=2*v[i-1]-x;
            x = ans[i];
        }
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    return  0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
using namespace std;
long long n, v, w; vector<int>C;
int main() {
	cin >> n;
	for (int i = 0; i < 60; i++) {
		if (n < ((1LL << i) - 1)) {
			for (int j = 1; j <= i - 1; j++)C.push_back(j);
			for (int j = 1; j <= i - 1; j++)C.push_back(j);
			n -= (1LL << (i - 1)) - 1; v = i - 1; w = i - 1; break;
		}
	}
	for (int i = v; i >= 0; i--) {
		if (n >= (1LL << i)) {
			vector<int>D;
			for (int j = 0; j < C.size() - i; j++)D.push_back(C[j]);
			w++; D.push_back(w);
			for (int j = C.size() - i; j < C.size(); j++)D.push_back(C[j]);
			D.push_back(w);
			n -= (1LL << i);
			C = D;
		}
	}
	cout << C.size() << endl;
	for (int i = 0; i < C.size(); i++) { if (i)cout << ' '; cout << C[i]; }cout << endl;
	return 0;
}

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

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

long long N, A[110], als, bob;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sort(A, A + SIZE_OF_ARRAY(A), greater<long long>());
	
	als += A[0];
	for (int i = 1; i < N; i++) {
		if (i % 2 == 0) {
			als += A[i];
		} else {
			bob += A[i];
		}
	}
	
	cout << als - bob << endl;
	return 0;
}


Measured memory_bytes: 888
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/25/20 20:57:10
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> A(n); for (auto& a:A) cin>>a;
  ll mon = 1000;
  ll kabu = 0;
  auto buy = [&](int i) {
    ll addk = mon/A[i];
    kabu += addk;
    mon -= addk*A[i];
  };
  auto cell = [&](int i) {
    ll addm = kabu*A[i];
    mon += addm;
    kabu = 0;
  };
  bool cup = false;
  for (int i = 0; i < n; i++) {
    if (i < n-1) {
      bool up = A[i]<A[i+1];
      if (A[i] != A[i+1]) {
        if (i == 0 or cup != up) {
          if (up) {
            buy(i);
          } else {
            cell(i);
          }
          cup = up;
        }
      }
    }
    if (i == n-1) {
      cell(i);
    }
  }
  cout << mon << endl;

  return 0;
}


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

int main(){
    char c;
    for(int i = 0; i < 10; ++i){
        scanf("%c", &c);
        if(i == 3){
            printf("8");
        }else{
            printf("%c", c);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n>>m;
	if(m % n == 0){
		cout << n + m << endl;
	}else{
		cout << m-n << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,Ans;
signed main(){
	cin>>N;
	int mn=inf;
	rep(i,N){
		int A,B;cin>>A>>B;
		Ans+=A;
		if(A>B)chmin(mn,B);
	}
	cout<<(mn!=inf?Ans-mn:0)<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<climits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238

#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        string sa;
        map<string, ll> m;
        for(i = 0; i < n; i++){
            cin >> sa;
            m[sa + " x "]++;
        }
        string s[4] = {"AC x ","WA x ", "TLE x ", "RE x "};
        for(i = 0; i < 4; i++){
            cout << s[i] << m[s[i]] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3664
module A = Array
module C = Char
module I = Int64
module L = List
module Q = Queue

let pf = Printf.printf
let sf = Scanf.scanf
let ssf = Scanf.sscanf

let read_int () = sf "%d " (fun x -> x)
let read_float () = sf "%f " (fun x -> x)
let read_str () = sf "%s " (fun x -> x)
let read_array n read () = A.init n (fun _ -> read ())
let err s = raise (Failure s)

let range s t = A.init (t - s) @@ (+) s
let foreach fold_f init s t map_f =
  range s t |> A.map map_f |> A.fold_left fold_f init

let inf = int_of_float 1e18
let eps = 1e-11

module S = struct
  include String
  let of_array a = String.init (A.length a) (A.get a)
  let to_array s = A.init (String.length s) (String.get s)
end;;

let rec sum_of_digit n =
  if n = 0
  then 0
  else sum_of_digit (n / 10) + n mod 10

let () =
  let n = read_int () in
  let f = read_array n (read_array 10 read_int) () in
  let p = read_array n (read_array 11 read_int) () in
  let res =
    let loop1 bit =
      let loop2 i =
        let f = f.(i) in
        let p = p.(i) in
        let loop3 t = (bit lsr t) land f.(t) in
        let cnt = foreach (+) 0 0 10 loop3 in
        p.(cnt) in
      foreach (+) 0 0 n loop2 in
    foreach max (-inf) 1 1024 loop1 in
  pf "%d\n" res


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
int main()
{
	cin>>n;
	for(long long l=1,r;l<=n;l=r+1)
	{
		r=(n/l)?(n/(n/l)):n;
		if(n/l==0) continue;
		long long tval=n/(n/l)-1;
		if(tval&&n/tval==n%tval) ans+=tval;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	long long a[n], dp[n];
	for( int i=0; i<n; ++i )
		scanf("%lld",a+i), dp[i] = 1000000000000000000;
	dp[n-1] = 0;
	for( int i=n-1; i>=0; --i )
		for( int j=k; j>=1; --j )
			if( i+j <= n-1 )
				dp[i] = min(dp[i], dp[i+j] + abs(a[i]-a[i+j]));
	printf("%lld\n", dp[0] );
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n+1], b[n+1], c[n+1];
	
	for (int i = 0; i < n; i ++)
	cin >> a[i] >> b[i] >> c[i];
	int dp[n+1][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	
	for (int i = 1; i < n; i ++)
	{
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i];
	}
	cout << max ( dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}

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

bool valid(int a, int b, int c){
    if (a == b || a == c || b == c){
        return false;
    }
    if (a + b <= c){
        return false;
    }
    if (a + c <= b){
        return false;
    }
    if (b + c <= a){
        return false;
    }
    return true;
}

int main(){
    int N, output = 0;
    cin >> N;
    int list[N];
    for (int i = 0; i<N; ++i){
        cin >> list[i];
    }
    for (int i = 0; i<N; ++i){
        for (int j = i; j<N; ++j){
            for (int k = j; k<N; ++k){
                if (valid(list[i], list[j], list[k])){
                    output++;
                }
            }
        }
    }
    cout << output << "\n";
}


Measured memory_bytes: 3584
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val Seq(a, b, c) = readLine.ints
    println(a.to(b).count(c % _ == 0))
  }
}

Measured memory_bytes: 44072
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
int n;
LL m, a[maxx];
LL lcm = 1LL, ans = 0LL;

LL Lcm(LL x, LL y) {
	LL g = __gcd(x, y);
	return x * y / g;
}

void Init() {
	scanf("%d %lld", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		a[i] >>= 1LL;
		lcm = Lcm(lcm, a[i]);
	}
}

void Solve() {
	//保证lcm只能是新a[i]的奇数倍
	//因为新a[i]是原a[i]除2得到的, 如果lcm是新a[i]的偶数倍, 相当于白除2了, 必然会整除原a[i]
	//故看m之内有多少个lcm的奇数倍
	//相邻的两个lcm的奇数倍相差2 * lcm
	//即看m - lcm内, 有多少个2 * lcm
	bool flg = 1;
	for(int i = 1; i <= n; i++) {
		if((lcm / a[i]) % 2LL == 0) {
			flg = 0;
			break;
		}
	}
	if(!flg) puts("0");
	else {
		if(lcm > m) puts("0");
		else {
			ans = 1LL;
			ans += (m - lcm) / (2LL * lcm);
			printf("%lld\n", ans);
		}
	}
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 1024
use proconio::input;
use std::collections::{HashSet, HashMap};

fn main() {
    input! {
        n: usize,
        v: [String; n],
    }

    let mut set = HashSet::new();
    for s in v {
        set.insert(s);
    }
    let ans = set.len();
    println!("{}", ans);
}


Measured memory_bytes: 24832
from sys import stdin
from itertools import accumulate
input = stdin.readline

INF = float('inf')

N = int(input())
*a, = map(int,input().split())

cost = [[0]*N for _ in range(N)]

prefix = [0]+ list(accumulate(a))

for i in range(1,N):
    for j in range(0,N-i):
        temp = INF
        for k in range(i):
            temp = min(temp,cost[j][j+k] + cost[j+k+1][j+i])
        cost[j][j+i] = temp + prefix[j+i+1] - prefix[j]


print(cost[0][N-1])


Measured memory_bytes: 46444
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n-1);
	rep(i, n-1) cin >> a[i];
	map<int, int> mp;
	for (int i = 1; i <= n; i++) {
		mp[i] = 0;
	}

	for (int i = 0; i < n - 1;i++) {
		mp.at(a[i])++;
	}

	for (int i = 1; i <= n; i++) {
		dunk(mp.at(i));
	}
	return 0;
}


Measured memory_bytes: 13556
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    A=list(map(int,input().split()))
    A.sort()
    a,b,c=A
    ans=0

    # a<=b=cにする
    ans+=c-b
    a+=c-b
    b=c

    # aとcの偶奇が一致するかどうか
    if((c-a)&1):
        ans+=(c-a+1)//2+1
    else:
        ans+=(c-a)//2
    print(ans)

resolve()

Measured memory_bytes: 38256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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


// 最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}



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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    vector<int> left(n+1, 0), right(n+1, 0);
    for(int i = 0; i < n; i++) left[i+1] = gcd(left[i], a[i]);
    for(int i = n-1; 0 <= i; i--) right[i] = gcd(right[i+1], a[i]);

    int res = 0;
    for(int i = 0; i < n; i++){
        int l = left[i];
        int r = right[i+1];
        chmax(res, gcd(l, r));
    }

    cout << res << endl;

    return 0;
}

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

public class Main {
    private static final int MOD = 1000000007;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.nextLine();

        final long[][] dpTable = new long[s.length() + 1][4];
        dpTable[s.length()][3] = 1;

        for (int i = s.length() - 1; i >= 0; i--) {
            final char character = s.charAt(i);

            dpTable[i][3] = character == '?' ? 3 * dpTable[i + 1][3] : dpTable[i + 1][3];
            dpTable[i][3] %= MOD;

            dpTable[i][2] = character == '?' ? 3 * dpTable[i + 1][2] : dpTable[i + 1][2];
            dpTable[i][2] += (character == '?' || character == 'C') ? dpTable[i + 1][3] : 0;
            dpTable[i][2] %= MOD;

            dpTable[i][1] = character == '?' ? 3 * dpTable[i + 1][1] : dpTable[i + 1][1];
            dpTable[i][1] += (character == '?' || character == 'B') ? dpTable[i + 1][2] : 0;
            dpTable[i][1] %= MOD;

            dpTable[i][0] = character == '?' ? 3 * dpTable[i + 1][0] : dpTable[i + 1][0];
            dpTable[i][0] += (character == '?' || character == 'A') ? dpTable[i + 1][1] : 0;
            dpTable[i][0] %= MOD;
        }
        
        System.out.println(dpTable[0][0]);
    }
}


Measured memory_bytes: 30396
import sys

#+++++

def compute_cc(a_ll):
	cp=False
	ccc=0
	for pre_c, c in zip(a_ll,a_ll[1:]):
		if cp == True:
			cp = False
			continue
		elif pre_c == c:
			cp=True
			ccc+=1
	return ccc	




def main():
	s = input()
	k = int(input())
	
	if len(s)==1:
		return k//2
	
	if len(s)==2:
		if s[0]==s[1]:
			return k
		else:
			return 0
	
	first_diff=None
	i=0
	for pre_c, c in zip(s,s[1:]):
		i+=1
		if pre_c != c and first_diff is None:
			first_diff=i
			#pa(i)
	
	if first_diff is None:
		return len(s) * k // 2
		
	
	#len(s)>=3
	pp=s[:first_diff]
	nn=s[first_diff:]
	nc=nn+pp
	a=0
	a+=compute_cc(pp)
	a+=compute_cc(nc)*(k-1)
	a+=compute_cc(nn)
	print(a)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
	ll n,k;
	cin>>n>>k;

    ll arr[n]={0};
    rep(i,0,k){
    	ll x;
    	cin>>x;
    	rep(i,0,x){
    		ll y;
    		cin>>y;
    		arr[y-1]=1;
    	}
    }
    ll cnt=0;
    rep(i,0,n){
    	if (!arr[i])cnt++;
    }
    cout<<cnt<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


// ref : https://kmjp.hatenablog.jp/entry/2020/05/02/0930

int n, a[200010], res[200010];
vector<int> v, g[200010];

void dfs(int now, int pre){
    int pos = lower_bound(v.begin(), v.end(), a[now]) - v.begin(); // 手持ちのLIS配列の中で、a[now]を入れる場所を探す
    int rev;
    if(pos == v.size()){ // a[now]がLISの最後尾につけられる場合
        rev = -1;
        v.push_back(a[now]);
    }
    else {
        rev = v[pos];
        v[pos] = a[now];
    }
    res[now] = v.size();

    for(auto nv : g[now]){
        if (nv != pre) dfs(nv, now);
    }

	if(rev == -1) v.pop_back(); // 最後尾につけた場合は、帰りがけに一段階前に巻き戻す
	else v[pos] = rev; // つけられない場合は、LISで更新した要素を一段階前に巻き戻す
}

int main(){
    cin >> n;
    rep(i, n) cin >> a[i];

    rep(i, n-1){
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs(0, -1);

    rep(i, n) cout << res[i] << endl;

    return 0;
}


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

using namespace std;

double roundOff(double);

int main(void){
	for(int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;){
		double delta = a * e - b * d;
		double x = roundOff((c * e - b * f) / delta);
		double y = roundOff((a * f - c * d) / delta);

        printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

double roundOff(double a){
	a*=1000;
	a = int(a + 0.5 - (a < 0));
	a/=1000.;
	return a;
}

Measured memory_bytes: 1192
#include<iostream>

using namespace std;

int fib(int n);

int main() {
  int n;

  //入力
  cin >> n;

  //出力
  cout << fib(n) << endl;

  return 0;
}

int fib(int n){
  int dp[1000];
  dp[0] = 1;
  dp[1] = 1;

  for(int i = 2; i <= n; i++){
    dp[i] = dp[i-1] + dp[i-2];
  }
  return dp[n];
}



Measured memory_bytes: 3104
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

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


Measured memory_bytes: 256
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		
		var x = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
		int ans = 0;
		for(int i=0;i!=5;i++){
			if(x[i]==0){
				ans = i+1;
			}
		}
		
		Console.WriteLine(ans);
		
		
	}
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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 a[110];
map<char,int> m;
int alpha[110][28];

int main() {
  string input;
  cin >> input;
  int N = input.length();


  for(int i=0;i<N;++i){
    a[i] = (char)(input[i]);
    ++m[a[i]];
  }

  FOR(i,0,N-1){
    ++alpha[i][(int)(a[i]-'a')];
  }
  int ans = 110;
  int count;
  int count_hold;
  FOR(j,0,25){
    count = 0;
    count_hold = 0;
    FOR(i,0,N-1){
      if(alpha[i][j]==0) ++count;
      else{
        chmax(count_hold,count);
        count = 0;
      }
    }
    chmax(count_hold,count);
    if(count_hold<ans){
      ans = count_hold;
      // cout << j << endl;
    }
  }

  cout << ans << endl;



}

Measured memory_bytes: 256
program main
  implicit none
  integer :: i, k, ant(5)

  do i = 1, 5
    read *, ant(i)
  end do
  read *, k

  if (maxval(ant) - minval(ant) > k) then
    print '(a)', ':('
  else
    print '(a)', 'Yay!'
  end if
end program

Measured memory_bytes: 256
#include <iostream>

int main() {
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    while(1){

        C = C-B;
        if(C <= 0){
            printf("Yes");
            return 0;
        }
        A = A - D;
        if(A <=0){
            printf("No");
            return 0;
        }

    }

}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int Ans=0;
    string S;
    cin >> S;
    int w=0;
    REP(i,S.size()){
        if(S[i]=='B')continue;
        Ans+=i-w;
        w++;
    }
    cout <<Ans <<  endl;
    return 0;
}   


Measured memory_bytes: 644
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        x: usize,
        a: usize,
        b: usize,
    }
    if a>=b {
        println!("delicious");
    } else if a<b && b<=(a+x) {
        println!("safe");
    } else {
        println!("dangerous");
    }
}


Measured memory_bytes: 2180
s = input()
q = int(input())

for qi in range(q):
    command = input().split()
    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + s[a:b + 1][::-1] + s[b + 1:]
    else:
        p = command[3]
        s = s[:a] + p + s[b + 1:]

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

using namespace std;

const int maxn = 5010;
int n, mod;

int f[4][maxn * 6];

int main() {
	scanf("%d%d", &n, &mod);
	n *= 3;
	f[0][n] = 1 % mod;
	for (int i = 1; i <= n; i++) {
		int l0 = (i-1+4)%4, l1 = (i-2+4)%4, l2 = (i-3+4)%4;
		int l = i % 4;
		for (int j = 0; j <= 2*n; j++) {
			f[l][j] = f[l0][j+1];
			if (i >= 2 && j) f[l][j] = (f[l][j] + 1LL * (i-1) * f[l1][j-1]) % mod;
			if (i >= 3) f[l][j] = (f[l][j] +  1LL * (i-1) * (i-2) * f[l2][j]) % mod;
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + f[n%4][i]) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3924
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K = MI()
    H = LI()
    H.sort(reverse=True)
    print(sum(H[K:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 105672
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int xor = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            xor ^= arr[i];
        }
        for (int i = 0; i < arr.length; i++) {
            arr[i] ^= xor;
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        
    }
}

Measured memory_bytes: 61324