akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll MOD = 998244353;

int main() {
    int n, k;
    cin >> n >> k;

    vector<pair<int, int>> lr(k);
    for (int i = 0; i < k; i++) { 
        int l, r;
        cin >> l >> r;
        lr[i] = {l, r};
    }

    vector<ll> dp(n);
    vector<ll> sdp(n + 1);
    dp[0] = 1;
    sdp[1] = 1;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < k; j++) {
            int left = max(0, i - lr[j].second);
            int right = max(0, i - lr[j].first + 1);
            dp[i] = (dp[i] + (sdp[right] - sdp[left])) % MOD;
        }
        sdp[i + 1] = sdp[i] + dp[i];
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 6432
#include <stdio.h>
#include <stdlib.h>

int dec(const void *b, const void *a) {
  return *(int *)a - *(int *)b;
}

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int x,y,a,b,c;
    int p[100000],q[100000],r[100000],rg[200000];

    scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
    int i,j;

    for (i = 0; i < a; i++)scanf("%d",&p[i]);
    for (i = 0; i < b; i++)scanf("%d",&q[i]);
    for (i = 0; i < c; i++)scanf("%d",&r[i]);

    qsort(p,a,sizeof(int),dec);
    qsort(q,b,sizeof(int),dec);
    qsort(r,c,sizeof(int),dec);

    long long ans = 0;
    j = 0;
    for (i = 0; i < x; i++)
    {
        ans += p[i];
        rg[j] = p[i];
        j++;
    }

    for (i = 0; i < y; i++)
    {
        ans += q[i];
        rg[j] = q[i];
        j++;
    }

    qsort(rg,j,sizeof(int),asc);

    int cntr = 0,cntrg = 0;
    for (i = 0; i < c; i++)
    {
        if(r[cntr] > rg[cntrg])
        {
            ans -= rg[cntrg];
            ans += r[cntr];
            cntr++;
            cntrg++;
        }
        else
        {
            break;
        }
    }
    
    printf("%lld",ans);
}


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

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    ll n, k;
    cin >> n >> k;

    double ans = 0.0;

    rep(i, n){
        ll x = i+1;
        double tmp = 1.0 / n;
        while(x < k){
            x *= 2;
            tmp /= 2.0;
        }
        ans += tmp;
    }

    cout << fixed;
    cout << setprecision(15) << ans  << endl;

    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:52:46 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

"""
N = int(input())

A = [0]*5

A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())

if N <= min(A):
    print(5)
    sys.exit()

n = N//min(A)
if N%min(A) ==0:
    pass
else:
    n += 1

print(n+5-1)




Measured memory_bytes: 15132
#include <stdio.h>
#include <string.h>

#define MAX 1000
#define max(a,b) (a < b ? b : a)

int main(){
  int Q,i,j,l1,l2,dp[MAX+1][MAX+1];
  char X[MAX+1],Y[MAX+1];
  scanf("%d",&Q);
  while(Q--){
    scanf("%s %s",X,Y);
    l1 = strlen(X);
    l2 = strlen(Y);
    memset(dp,0,sizeof(dp));
    for(i = 0 ; i < l1 ; i++){
      for(j = 0 ; j < l2 ; j++){
        if(X[i] == Y[j]){
          dp[i+1][j+1] = dp[i][j] + 1;
        }else{
          dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
      }
    }
    printf("%d\n",dp[l1][l2]);
  }
  return 0;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < w + 2; i++)
    {
        cout << '#';
    }

    cout << endl;

    char x;

    for (int i = 0; i < h; i++)
    {
        cout << '#';
        for (int j = 0; j < w; j++)
        {
            cin >> x;
            cout << x;
        }

        cout << '#'<<endl;
    }

    for (int i = 0; i < w + 2; i++)
    {
        cout << '#';
    }

    cout << endl;
    
}

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

int GCD(int a,int b){
    int c=1;
    if(a<b)swap(a,b);
    while(c>0){
        c=a-((int)a/b)*b;
        a=b;
        b=c;
    }
    return a;
}


int main(){
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++)cin>>A.at(i);

    vector<int> L(N),R(N);
    L.at(0)=A.at(0);
    R.at(N-1)=A.at(N-1);
    for(int i=1;i<N;i++){
        L.at(i)=GCD(L.at(i-1),A.at(i));
        R.at(N-i-1)=GCD(R.at(N-i),A.at(N-i-1));
    }

    int gcd,Max=0;
    for(int i=0;i<N;i++){
        if(i==0)gcd=R.at(1);
        else if(i==N-1)gcd=L.at(N-2);
        else{
            gcd=GCD(L.at(i-1),R.at(i+1));
        }
        Max=max(Max,gcd);
    }

    cout<<Max<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int n;
    cin>>n;
    if(n==0)cout<<1<<endl;
    else cout<<0<<endl;

}

Measured memory_bytes: 3592
n,q=map(int,input().split())
s=list(input())
x=[[] for i in range(q)]
for i in range(q):
    l,r=map(int,input().split())
    x[i].append(l)
    x[i].append(r)
ans=[0 for i in range(n+1)]
if s[0]=="A" and s[1]=="C":
    ans[2]=1
for i in range(3,n+1):
    if s[i-1]=="C" and s[i-2]=="A":
        ans[i]=ans[i-1]+1
    else:
        ans[i]=ans[i-1]
for i in range(q):
    print(ans[x[i][1]]-ans[x[i][0]])
        


Measured memory_bytes: 28644
#include<stdio.h>

long long factorial(int n)
{
    if(n==1)
        return 1;
    else
        return(n*factorial(n-1));
}

int main()
{
    int n;
    long long f;


    while(scanf("%d",&n)==1)
    {
       if(n<=0)
            printf("no factorial.\n");
        else

        {
            f=factorial(n);
            printf("%lld\n",f);
        }
    }
    return 0;

}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
using namespace std;
int solve(int, int, int);

int main(void){
  int n,m,l;

  while(cin >> n >> m, n != 0 && m != 0){
    int ans = 0;
    int a[3] = {0}, temp;

    for(int i = 0; i < 3; i++){
      cin >> l;
      for(int j = 0; j < l; j++){
	cin >> temp;
	a[i] |= 1 << temp - 1;
      }
    }

    ans = min(solve(a[0], a[1], a[2]), solve(a[2], a[1], a[0]));

    if(ans > m)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }

  return 0;
}

int solve(int a, int b, int c){
  if(a == 0 && b == 0) return 0;
  if(c & 1) return solve(a >> 1, b >> 1, c >> 1);
  if(b & 1) return solve(c >> 1, b >> 1, a >> 1) + 1 + solve((a|b|c) >> 1, 0, 0);
  if(a & 1) return solve(a >> 1, b >> 1, c >> 1) + 2*solve((a|b|c) >> 1, 0, 0) + 2;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,string>
#define MP make_pair
#define pb push_back
#define ll long long int
#define fill(v,d) memset(v,d,sizeof(v))
#define INF 0x3f3f3f3f
ll readli()
{
    register char c;
    for(c=getchar(); !(c>='0' && c<='9'); c=getchar());
    register long a=c-'0';
    for(c=getchar(); c>='0' && c<='9'; c=getchar())
        a=(a<<3)+(a<<1)+c-'0';
    return a;
}
template<class R,class E>
R find(R first,R last,const E& value)
{
  while(first!=last && *first!=value) first++;
  return first;
}
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int a,b,c;
   bool flag=false;
   cin>>a>>b>>c;
   if(a==b+c || b==a+c || c==a+b)
    flag=true;
   if(flag)
    cout<<"Yes";
   else
    cout<<"No";
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string N;
  cin >> N;
  string m;
  m += N[0];
  rep(i, N.size()-1)  m += '9';
  if(m > N)
    m[0]--;
  int ans = 0;
  rep(i, m.size()) ans += m[i]-'0';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <algorithm>

int main() {
	int64_t n, k;
	std::cin >> n >> k;

	if (k == 0) {
		std::cout << n * n << std::endl;
		return 0;
	}

	int64_t ans = 0;
	for (int64_t b = k + 1; b <= n; ++b) {
		ans += n / b * (b - k);
		ans += std::max<int64_t>(0, n - n / b * b - k + 1);
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cmath>
#include<cctype>
using namespace std;

enum FACE { TOP,BACK, RIGHT ,LEFT , FRONT,  BOTTOM};
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (int f) { return var[id[f]]; }
  const T& operator[] (int f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_n() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_s() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_e() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_w() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

int main()
{
	vector<dice<int>> d(2);
	for(int j=0;j<2;j++)
	for(int i=0;i<6;i++){
		int n; cin >>n;
		d[j][i] = n;
	}
	if(d[0].equivalent_to(d[1])){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	/*int n;cin >> n;
	for(int i=0;i<n;i++){
		int top,back;
		cin >> top >> back;
		for(int i=0;i<vd.size();i++){
			if(vd[i][TOP] == top && vd[i][BACK] == back){
				cout << vd[i][RIGHT] << endl;
				break;
			}
		}
	}*/
    return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
typedef long long LL;
const int N=4005,M=200005,mo=1000000007;
int a[M],b[M],f[N][N];
LL fac[N*2],inv[N*2];
LL ksm(LL x,LL y){
	LL i=1;
	for (;y;y>>=1,x=x*x%mo)
		if (y&1) i=i*x%mo;
	return i;
}
void Pre(int n){
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	for (int i=n;i>=1;i--) inv[i-1]=inv[i]*i%mo;
}
LL C(int n,int m){
	return fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
	int n,X=0,Y=0;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		if (a[i]>X) X=a[i];
		if (b[i]>Y) Y=b[i];
	}
	for (int i=1;i<=n;i++) f[-a[i]+X][-b[i]+Y]++;
	for (int i=1;i<=X*2;i++) f[i][0]+=f[i-1][0];
	for (int i=1;i<=Y*2;i++) f[0][i]+=f[0][i-1];
	for (int i=1;i<=X*2;i++)
		for (int j=1;j<=Y*2;j++)
			(f[i][j]+=f[i-1][j]+f[i][j-1])%=mo;
	Pre((X+Y)*2);
	int ans=0;
	for (int i=1;i<=n;i++)
		ans=(ans+f[a[i]+X][b[i]+Y]-C((a[i]+b[i])*2,a[i]*2))%mo;
	ans=ans*inv[2]%mo;
	printf("%d\n",(ans+mo)%mo);
}

Measured memory_bytes: 64512
def main():
    n = int(input())
    h = list(map(int, input().split()))
    
    pre = h[0]
    now = -1
    ans = 0
    for hh in h:
        if hh <= pre:
            now += 1
            ans = max(ans, now)
        else:
            now = 0
        pre = hh
    print(ans)
    
if __name__ == '__main__':
    main()

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll P = 2019;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll l, r;
  cin >> l >> r;
  if (r - l > 2019) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019 * 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++)
      ans = min(ans, (i % P * j % P) % P);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n;

	while (cin >> n) {
		int count = 0;
		bool table[1000001] = { false };
		int upper = sqrt(n);

		table[1] = true;

		for (int i = 1; i <= upper; i++) {
			if (table[i] == false) {
				table[i] = true;
				count++;
				for (int j = i; j <= n; j += i) {
					table[j] = true;
				}
			}
		}

		for (int i = upper; i <= n; i++) {
			if (table[i] == false) {
				count++;
			}
		}

		cout << count << '\n';
	}

	return 0;
}

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

using namespace std;

int main(){
	string n; cin >> n;
	int x = atoi(n.c_str());
	int f = 0;
	for(int i = 0; i < n.size(); i++){
		f += n[i] - '0';
	}
	if(x % f == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n,MOD = [int(i) for i in input().split()]

to = [[] for _ in [0]*n]
for _ in range(n-1):
    x,y = [int(i)-1 for i in input().split()]
    to[x].append(y)
    to[y].append(x)


dp = [[0]*len(to_i) for to_i in to]
parent_index = [-9999]*n 
ans = [0]*n

def dfs(v, p):
    res = 1
    for i, vc in enumerate(to[v]):
        if vc == p:
            parent_index[v] = i
            continue
        dp[v][i] = dfs(vc, v)
        res *= dp[v][i]+1
        res %= MOD
    return res

def dfs2(v, res_p, p):
    deg = len(to[v])
    if p >= 0:
        dp[v][parent_index[v]] = res_p

    accl = [1]*(deg+1)
    accr = [1]*(deg+1)

    for i in range(1, deg+1):
        accl[i] = accl[i-1] * (dp[v][i-1] + 1) % MOD
        accr[-i-1] = accr[-i] * (dp[v][-i] + 1) % MOD

    ans[v] = accr[0]
    for i,vc in enumerate(to[v]):
        if vc == p: continue
        dfs2(vc, accl[i]*accr[i+1]%MOD, v)

dfs(0,-1)
#print(dp)
dfs2(0,0,-1)
#print(dp)
for i in ans:
    print(i)

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

int main(){
	const ll MOD = 1000000007;
	int N; 
	cin >> N;
	string s1, s2;
	cin >> s1 >> s2;

	ll res = 1;
	vector<vector<bool>> colored(2, vector<bool>(N, false));
	if (s1[0] == s2[0]){
		res = 3;
		colored[0][0] = true;
		colored[1][0] = true;
	} else {
		res = 3 * 2;
		colored[0][0] = true;
		colored[0][1] = true;
		colored[1][0] = true;
		colored[1][1] = true;
	}
	for (int i = 1; i < N; i++){
		if (colored[0][i]) continue;

		if (s1[i] == s2[i]){
			if (s1[i-1] == s2[i-1]){
				res = (res * 2) % MOD;
			}
			colored[0][i] = true;
			colored[1][i] = true;
		} else {
			if (s1[i-1] == s2[i-1]){
				res = (res * 2) % MOD;
			} else {
				res = (res * 3) % MOD;
			}
			colored[0][i] = true;
			colored[0][i+1] = true;
			colored[1][i] = true;
			colored[1][i+1] = true;
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var):
    print(*var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
# from collections import defaultdict as dd, Counter
# from bisect import bisect_left as bl, bisect_right as br

n, = I()
a = [i-1 for i in I()]
ans = 1
if 0 in a:
    cur = 0
    ans = 0
    for i in range(n):
        if a[i] == cur:
            ans += 1
            cur += 1
    print(n - ans)
else:
    print(-1)

Measured memory_bytes: 123160
N = int(input())
A = [-1] + [int(input()) for _ in range(N)]

on = 1
cnt = 0
while True:
    if on == 2:
        print(cnt)
        break
    elif on == A[on]:
        print('-1')
        break
    elif cnt >= N-1:
        print('-1')
        break

    on = A[on]
    cnt += 1


Measured memory_bytes: 7852
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int N;
string S;

int main()
{
  int n;
  int ret=0;

  cin >> S;

  if (S == "AAA" || S == "BBB")
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}


Measured memory_bytes: 256
d = int(input())
c_l = list(map(int,input().split()))
s_l = [list(map(int,input().split())) for i in range(d)]

t_l = [int(input()) for i in range(d)]

last_l = [-1 for i in range(26)]

ans = 0
for day in range(d):
  contest_num = t_l[day]
  contest_num -= 1

  contest_val = s_l[day][contest_num]

  ans += contest_val
  last_l[contest_num] = day

  for i in range(26):
    ans -= c_l[i] * (day - last_l[i])

  print(ans)

Measured memory_bytes: 9392
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		 String input = in.readLine();
		 Integer result = (int) Math.pow(Integer.parseInt(input), 3);
		 System.out.println(result);
	}

}

Measured memory_bytes: 17072
#include<stdio.h>
#include<string>
#include<algorithm>

#define MAX 100000
#define NIL -1


struct Node {
    public:
        int id;
        int parent;
        int left;
        int right;
        int height;
        int depth;
        int sibling;
        int degree;
};

Node N[MAX];

void setDepth(Node& n, int depth) {
    Node* cur = &n;
    cur->depth = depth;
    if (cur->right != NIL) setDepth(N[cur->right], depth + 1);
    if (cur->left != NIL) setDepth(N[cur->left], depth + 1);
}

int setHeight(Node& n) {

    int hl = 0, hr = 0;
    if (n.left != NIL) {
        hl = setHeight(N[n.left]) + 1;
    }
    if (n.right != NIL) {
        hr = setHeight(N[n.right]) + 1;
    }

    return n.height = std::max(hl, hr);
}


void print(Node n, int id) {
    std::string type;
    if (n.parent == NIL) {
        type = "root";
    }
    else if (n.left == NIL && n.right == NIL) {
        type = "leaf";
    }
    else {
        type = "internal node";
    }

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", id, n.parent, n.sibling, n.degree, n.depth, n.height, type.c_str());
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        N[i].id = i;
        N[i].parent = NIL;
        N[i].left = NIL;
        N[i].right = NIL;
        N[i].height = NIL;
        N[i].depth = NIL;
        N[i].sibling = NIL;
        N[i].degree = NIL;
    }

    for (int i = 0; i < n; ++i) {
        int id, lc, rc;
        scanf("%d %d %d", &id, &lc ,&rc);
        N[id].left = lc;
        N[id].right = rc;

        int deg = 0;
        if (lc != NIL) {
            ++deg;
            N[lc].parent = id;
            if (rc != NIL) N[lc].sibling = rc;
        }
        if (rc != NIL) {
            ++deg;
            N[rc].parent = id;
            if (lc != NIL) N[rc].sibling = lc;
        }

        N[id].degree = deg;
    }

    int root = NIL;
    for (int i = 0; i < n; ++i) {
        if (N[i].parent == NIL) {
            root = i;
            break;
        }
    }

    setDepth(N[root], 0);
    setHeight(N[root]);

    for (int i = 0; i < n; ++i) print(N[i], i);

}

Measured memory_bytes: 2836
object Main extends App{
  var a = readInt
  var b = 0
  for (v1 <- 0 to a / 4; v2 <- 0 to a / 7) {
  	if(v1 * 4 + v2 * 7 == a){
      b =  b + 1
    }
  }
  if(b!=0){
    print("Yes")
  } else {
    print("No")
  }
}

Measured memory_bytes: 25420
#include <iostream>
using namespace std;
const int inf = 2e9;
const int N = 500100;

int n , a[N],sum;
int L[N/2+2], R[N/2+2];

/******???a[1]??°a[n]????°???°??§**************/
void Merge(int a[], int p, int q, int r)
{
	int i, j, n1 = q - p + 1, n2 = r - q;
	for (i = 1; i <= n1; i++)
		L[i] = a[p + i - 1];
	for (j = 1; j <= n2; j++)
		R[j] = a[q + j];
	L[n1 + 1] = inf;
	R[n2 + 1] = inf;
	i = j = 1;
	for (int k = p; k <= r; k++)
	{
		sum++;
		if (L[i] <= R[j])
		{
			a[k] = L[i];
			i++;
		}
		else
		{
			a[k] = R[j];
			j++;
		}
	}
}
void MergeSort(int a[], int p, int r)
{
	int q;
	if (p<r)
	{
		q = (p + r) / 2;
		MergeSort(a, p, q);
		MergeSort(a, q + 1, r);
		Merge(a, p, q, r);
	}
}
/*************************/
void print(int a[], int n)
{
	for (int i = 1; i <= n; i++) {
		cout << a[i];
		if (i != n) cout << " ";
	}	
	cout << endl;
}
int main()
{
	int n;
	sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	MergeSort(a,1, n);
	print(a, n);
	cout << sum << endl;
	return 0;
}

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	a.push_back(x);
	sort(a.begin(), a.end());
	vector<int>b;
	for (int i = 0; i < n; i++)b.push_back(a.at(i + 1) - a.at(i));
	sort(b.begin(), b.end());
	//数列の最大公約数を求める
	ll ans = 1;
	ll c = 2;
	while (c <= b.at(0)) {
		bool m = true;
		for (int i = 0; i < b.size(); i++) {
			if (b.at(i) % c != 0) {
				m = false;
				break;
			}
		}
		if (m) {
			ans *= c;
			for (int i = 0; i < b.size(); i++)b.at(i) /= c;
		}
		else c++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    string s, t; cin >> s >> t;
    const int n = s.length(), m = t.length();

    auto dp = make_v(n + 1, m + 1, 0);

    s = " " + s, t = " " + t;

    function<int(int, int)> rec = [&](int i, int j) {
        if (i == 0 || j == 0) {
            return max(i, j);
        }
        
        if (dp[i][j]) {
            return dp[i][j];
        }

        int ret = 1e5;
        ret = min(ret, rec(i - 1, j - 1) + (s[i] != t[j]));
        ret = min(ret, rec(i - 1, j) + 1);
        ret = min(ret, rec(i, j - 1) + 1);

        return dp[i][j] = ret;
    };
    
    cout << rec(n, m) << endl;

    return 0;
}



Measured memory_bytes: 6840
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const int maxn = 5e5 + 50;
typedef pair<int, int> P;

int arr[maxn];
int a, b, c, d, e, f, g;
void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=0; i<t; i++)
	{
		solve();
	}
	return 0;
}

// type below

void solve()
{
	cin >> a;
	int ans = 1000 * (a / 500);
	ans += 5 * (a % 500 / 5);
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;


int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vi x(N);
    vi y(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];
    x.pb(X); y.pb(Y);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if (x[N] < y[0]) cout << "No War" << endl;
    else cout << "War" << endl;

}

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

int main() {
    ll n, dp1[MAX_N]{}, dp2[MAX_N]{}, cnt[3][MAX_N]{};
    string s, t = "JOI";
    cin >> n >> s;

    // J,O,Iそれぞれの個数の累積和を求める
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            if(s[i]==t[j]) cnt[j][i+1]++;
            cnt[j][i+1] += cnt[j][i];
        }
    }

    // JO,OIの部分列の個数を求める
    for(int i=0; i<n; i++){
        if(s[i]=='O') dp1[i+1] += cnt[0][i];
        if(s[i]=='I') dp2[i+1] += cnt[1][i];
        dp1[i+1] += dp1[i];
        dp2[i+1] += dp2[i];
    }

    // 元のJOIの部分列の個数を求める
    // Oそれぞれの(左のJの個数)*(右のIの個数)の総和
    ll ans = 0, add = 0;
    for(int i=0; i<n; i++){
        if(s[i]=='O') ans += cnt[0][i]*(cnt[2][n]-cnt[2][i]);
    }

    // Oを挿入する位置を全探索
    for(int i=0; i<n; i++){
        add = max(add, cnt[0][i]*(cnt[2][n]-cnt[2][i]));
    }
    // Jを挿入するなら先頭,Iを挿入するなら末尾が最善
    add = max(add, dp1[n]);
    add = max(add, dp2[n]);

    ans += add;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 7220
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = scan.nextInt();
		String[] ret = new String[n];
		for (int i = 1; i <= n; i++) {
			ret[scan.nextInt() - 1] = String.valueOf(i);
		}
		out.println(String.join(" ", ret));
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 31404
class UnionFind(object):

    def __init__(self, n):
        # 親のnodeを表す
        self.par = [i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            # 経路圧縮
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        self.par[x] = y


class UnionFindRank(UnionFind):

    def __init__(self, n):
        UnionFind.__init__(self, n)

        self.rank = [0 for _ in range(n)]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

def _abc049_d():
    """連結"""

    N, K, L = list(map(int, input().split(' ')))
    ur = UnionFindRank(N)
    for _ in range(K):
        p, q = list(map(int, input().split(' ')))
        p -= 1
        q -= 1
        ur.union(p, q)

    ut = UnionFindRank(N)
    for _ in range(L):
        r, s = list(map(int, input().split(' ')))
        r -= 1
        s -= 1
        ut.union(r, s)

    def _id(r, t):
        return r * 1e8 + t

    from collections import defaultdict
    d = defaultdict(int)

    ids = []
    for i in range(N):
        __id = _id(ur.root(i), ut.root(i))
        d[__id] += 1
        ids.append(__id)

    for i in range(N):
        print(d[ids[i]], end=' ')

_abc049_d()

Measured memory_bytes: 46424
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int main () {
  string X;
  cin >> X;
  int cntS = 0, cntT = 0;
  for (auto x : X) {
    if (x == 'S') {
      cntS++;
    } else if (x == 'T' && cntS > 0) {
      cntS--;
    } else {
      cntT++;
    }
  }
  cout << cntT * 2 << endl;
}


Measured memory_bytes: 1152
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b

n,c=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[[0]*(10**5+10) for i in range(c)]
for i in a:
    b[i[2]-1][i[0]-1]+=1
    b[i[2]-1][i[1]]-=1
b=[Csum(i) for i in b]
ans=[]
for i in range(10**5+10):
    d=0
    for j in range(c):
        if b[j][i]>0:
            d+=1
    ans.append(d)
print(max(ans))

Measured memory_bytes: 74352
import std.stdio, std.range, std.conv, std.string, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

void main() {
    long N = readln().strip.to!long;
    long minCount=long.max;
    for (long i = 0; i < 5; ++i) {
        long n = readln().strip.to!long;
        minCount = min(n, minCount);
    }
    writeln(ceil(N/(minCount.to!real)-1).to!long+5);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    map<int,int> m;
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        m[x]++;
    }
    int res = 0;
    for(auto i:m){
        if(i.first>i.second){
            res+=i.second;
        }
        else{
            res+=i.second-i.first;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int i = 0;
  while (i < S.size()) {
    if (S.at(i) != T.at(i)) {
      cout << "No" << endl;
      break;
    }
    i++;
  }
  if (i == S.size()) {
    cout << "Yes" << endl;
  }
}

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

int main() {
  vector<int> kind(3);
  for(int i=0;i < 3;i++) {
    cin >> kind.at(i);
  }
  sort(kind.begin(),kind.end());
  int answer =3;
  if(kind.at(0) == kind.at(1)) {
    answer --;
  }
  if(kind.at(2) == kind.at(1)) {
    answer --;
  }
  cout << answer << endl;
}

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

int main() {
  char A,B;
  cin >> A >> B;
  if ((A == 'H' && B == 'H') || (A == 'D' && B == 'D')) {
    cout << 'H' << endl;
  }
  else {
    cout << 'D' << endl;
  }
}

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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
int jud(int x){
	
	if(x%2==0)return x/2;
	else return (3*x)+1;
}
int D;
int cnt=0;
int m[10000001]={0};
string str= "Christmas Eve Eve Eve";

void solve(){
	
	cin>>D;
	
	if(D==25)cout<<str.substr(0,9);
	if(D==24)cout<<str.substr(0,13);
	if(D==23)cout<<str.substr(0,17);
	if(D==22)cout<<str.substr(0,21);
	

}


int main(){

    solve();
    return 0;
}




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

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

int main() {
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

template <class X>
void printarr(X arr[], int n) 
{
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
	ll ans = 1;
	while (n) 
	{
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() 
{
	string s; cin >> s;
	int q; cin >> q;
	int curr = 1;
	string beg = "";
	string end = "";
	while (q--)
	{
		int x; cin >> x;
		if (x == 1)
		{
			curr *= -1;
		}
		else
		{
			int f; char c; cin >> f >> c;
			if (f == 1)
			{
				if (curr == 1)
				{
					beg += c;
				}
				else
				{
					end += c;
				}
			}
			else
			{
				if (curr == 1)
				{
					end += c;
				}
				else
				{
					beg += c;
				}
			}
		}
	}
	reverse(all(beg));
	s = beg + s;
	s += end;
	if (curr == -1)
	{
		reverse(all(s));
	}
	cout << s << endl;
}

int main() 
{
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

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

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

    int n, k;
    string s;
    cin >> n >> s >> k;
    for (int i = 0; i < n; i++) {
        if (s[k-1] != s[i])
            cout << '*';
        else
            cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

typedef long long ll;

const int MAX_N = 50;

int main(int argc, char const *argv[]) {
  int n, p, a[MAX_N];
  int oe[2]={0};
  cin >> n >> p;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);

  for (int i = 0; i < n; ++i) oe[a[i]%2]++;
  ll ans = 0, evens[MAX_N], odds[MAX_N], kai[MAX_N];
  evens[0] = 1;
  for (int i = 0; i <= oe[0]; ++i) {
    evens[i+1] = evens[i] * (oe[0]-i);
    evens[i+1] /= (i+1);
  }
  odds[0] = 1;
  for (int i = 0; i <= oe[1]; ++i) {
    odds[i+1] = odds[i] * (oe[1]-i);
    odds[i+1] /= (i+1);
  }
  kai[0] = 1;
  for (int i = 1; i <= n; ++i) kai[i] = kai[i-1]*i;

  ll even = 0, odd = 0;
  for (int i = 0; i <= oe[0]; ++i) even += evens[i];

  if (p==0) {
    for (int i = 0; i <= oe[1]; i+=2) {
      odd += odds[i];
    }
  }
  else {
    for (int i = 1; i <= oe[1]; i+=2) {
      odd += odds[i];
    }
  }

  ans = odd*even;

  cout << ans << endl;

  return 0;
}


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

int main() {
    long M, N;
    cin >> N >> M;
    long sum = 0;
    for(int i = 0; i < M; i++){
        int T;
        cin >> T;
        sum += T;
    }
    N -= sum;
    if(N < 0) N = -1;
    cout << N << "\n";
    return 0;
}

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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll i,ans=0;
	string ss;
	stack<char> s;
	cin>>ss;
	for(i=0;i<ss.length();i++){
		if(s.size()>0){
		if(s.top()=='0' && ss[i]=='1'){
			s.pop();
			ans++;
			continue;
		}if(s.top()=='1' && ss[i]=='0'){
			s.pop();
			ans++;
			continue;
		}
		}s.push(ss[i]);
	}cout<<ans*2;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	maxAbsIndex := 0

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
		if Abs(a[i]) > Abs(a[maxAbsIndex]) {
			maxAbsIndex = i
		}
	}

	fmt.Println(2*n - 1)

	for i := range a {
		fmt.Println(maxAbsIndex+1, i+1)
	}

	if a[maxAbsIndex] < 0 {
		for i := n; i > 1; i-- {
			fmt.Println(i, i-1)
		}
	} else {
		for i := range a[:len(a)-1] {
			fmt.Println(i+1, i+2)
		}
	}
}

func Abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
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;
}
int main() {
    long long N;
    cin >> N;
    string ans;
    int rem;
    rem = (N-1)%26;
    ans = char(97+rem);
    N = (N - rem)/26;
    while (N > 0) {
        rem = (N-1)%26;
        ans = char(97+rem) + ans;
        N = (N - rem)/26;
    }
    
    cout << ans << endl;
}



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

int main(){
  int w,h,x,y;cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int num = (w==x*2&&h==y*2) ? 1:0;
  cout << ans << " " << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int n, d, ans = 0;
    cin >> n >> d;
    int x[n][d];
    rep(i, n) {
        rep(j, d) { cin >> x[i][j]; }
    }
    rep(i, n) {
        rep(j, i) {
            double tmp = 0;
            rep(k, d) { tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]); }
            int tmp2 = round(sqrt(tmp));
            if (tmp2 * tmp2 == tmp)
                ans++;
        }
    }

    cout << ans << endl;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;


void solve(long long N, std::vector<long long> B) {
	int res = B[0];
	rep(i, N-2) {
		res += min(B[i], B[i+1]);
	}
	cout << res + B.back() << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	std::vector<long long> B(N-1);
	for(int i = 0 ; i < N-1 ; i++){
		scanf("%lld",&B[i]);
	}
	solve(N, std::move(B));
	return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, K = getNM()
A = getList()
if K in A:
    print('POSSIBLE')
    exit()
if K > max(A):
    print('IMPOSSIBLE')
    exit()

gc = A[0]
for i in range(N):
    gc = gcd(gc, A[i])

if K % gc == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 101248
require 'pp'

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end
str = gets_s
s_list = str.chars
s_count_hash = s_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

chars = ("a".."z").to_a
counts = chars.map do |char|
  count = 0
  duped_s_list = s_list.dup
  while duped_s_list.uniq.size != 1 do
    duped_s_list.pop
    duped_s_list.size.times do |i|
      duped_s_list[i] = char if duped_s_list[i+1] == char
    end
    count += 1
  end
  count
end
puts counts.min

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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<double> ps(N + 1);
  rep(i, N) cin >> ps[i + 1];

  vector<vector<double> > dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1.0;
  rep(i, N) rep(j, N) {
    dp[i + 1][j] += dp[i][j] * (1.0 - ps[i + 1]);
    dp[i + 1][j + 1] += dp[i][j] * ps[i + 1];
  }
  double sum = 0.0;
  for (int j = N / 2 + 1; j <= N; j++) {
    sum += dp[N][j];
  }
  printf("%.9f\n", sum);
  return 0;
}

Measured memory_bytes: 73808
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;

    priority_queue<ll> que;
    rep(i, n){
        ll a;
        cin >> a;

        que.push(a);
    }

    rep(i, m){
        ll top = que.top() / 2;
        que.pop();
        que.push(top);
    }

    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 4320