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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	int Max = -1 , now = 1 ;
	int idx = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(abs(arr[i]) > Max)
		{
			idx = i ;
			Max = abs(arr[i]) ;
			if(arr[i] >= 0)
				now = 1 ;
			else
				now = -1 ;
		}
		else if(abs(arr[i]) == Max && arr[i] >= 0)
			idx = i , now = 1 ;
	}
	vector< pair<int , int> >ans ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(idx == i)
			continue ;
		ans.push_back({idx , i}) ;
		arr[i] += (now * Max) ;
	}
	int cnt = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(arr[i] >= 0)
			cnt++ ;
	}
	//debugging
	if(cnt != n && cnt != 0)
		while(1) ;
	if(cnt == n)
	{
		for(int i = 0 ; i < n-1 ; ++i)
			ans.push_back({i , i+1}) ;
	}
	else
	{
		for(int i = n-1 ; i >= 1 ; --i)
			ans.push_back({i , i-1}) ;
	}
	cout<<ans.size()<<"\n";
	for(auto &i : ans)
		cout<<i.first+1<<" "<<i.second+1<<"\n";
	return 0 ;
}

Measured memory_bytes: 256
a,b,m=map(int,input().split())
ai=list(map(int, input().split()))
bi=list(map(int, input().split()))
sm=[list(map(int, input().split())) for _ in range(m)]
k=min(ai)+min(bi)

for x in range(m):
    
    l=ai[sm[x][0]-1]+bi[sm[x][1]-1]-sm[x][2]
    k=min(k,l)

print(k)


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

#define fi first
#define se second
typedef long long ll;

const int len = 1e5+5;
int l[len], r[len], sz[len];
priority_queue<ll> pq1;
priority_queue<ll, vector<ll>, greater<ll> > pq2;

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d %d", &l[i], &r[i]);
        sz[i] = r[i]-l[i];
    }

    ll k1 = 0, k2 = 0, ans = 0, opt;
    for (int i = 1; i <= n; i++){
        if (i == 1){
            pq1.push(l[i]);
            pq2.push(l[i]);

            opt = pq1.top() + k1;
        }
        else{
            k1 -= sz[i], k2 += sz[i-1];
            ll a = pq1.top() + k1, b = pq2.top() + k2;

            if (l[i] < a){
                pq1.pop();
                pq2.push(a-k2);

                pq1.push(l[i]-k1);
                pq1.push(l[i]-k1);

                opt = pq2.top() + k2;
            }
            else if (b < l[i]){
                pq2.pop();
                pq1.push(b-k1);

                pq2.push(l[i]-k2);
                pq2.push(l[i]-k2);

                opt = pq1.top() + k1;
            }
            else{
                pq1.push(l[i]-k1);

                pq2.push(l[i]-k2);

                opt = pq1.top() + k1;
            }
        }

        //opt = pq2.top() + k2;
        ans += abs(l[i] - opt);

        //printf("i = %d, opt = %lld\n", i, opt);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3188
import numpy as np
N,K = map(int,input().split())
ans = np.full(N,1/N)
ans_2 = np.array(range(N))
ans_2 += 1
prob = 0
for i in range(N):
	if ans_2[N-i-1] >= K:
		prob += ans[N-i-1]
	else:
		while ans_2[N-i-1] < K:
			ans_2 *= 2
			ans *= 1/2
		prob += ans[N-i-1]
print(prob)

Measured memory_bytes: 14024
from heapq import heappush, heappop, heapify
n,m=map(int,input().split())
a_1=list(map(int,input().split()))
a=list(map(lambda x:x*(-1),a_1))
heapify(a)
for i in range(m):
    b=(-1)*heappop(a)
    heappush(a,(-(b//2)))
print(-sum(a))

Measured memory_bytes: 20224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define endl '\n'
#define ll long long
using namespace std;

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

	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t;

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<pll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<61);
const ll SKIP = 1;

int main() {
  int V, E, T; cin >> V >> E;
  vvl edges(V, vl(V, -1));
  vector<bool> go(V, false);
  vl depth(V, INF);
  vl ans;

  rep(i,E) {
    int u, v, d;
    scanf("%d %d %d", &u, &v, &d);
    edges[u-1][v-1] = edges[v-1][u-1] = d;
  }
  cin >> T;
  vl ids(T), dsts(T);
  rep(i,T) {
    int n; scanf("%d", &n);
    if (n == 0) {
      ids[i] = 0; dsts[i] = 0;
    } else {
      scanf("%d %d", &ids[i], &dsts[i]);
      dsts[i]--;
    }
  }

  pq que;
  que.push(mp(0, 0));
  while (!que.empty()) {
    pll x = que.top(); que.pop();
    ll dep = x.ff, node = x.ss;
    if (depth[node] == INF) {
      // cout << node+1 << ": " << -dep << endl;
      depth[node] = -dep;
    }
    rep(i,V) {
      if (edges[node][i] != -1 && depth[i] == INF) {
        que.push(mp(dep - 1, i));
      }
    }
  }

  int t = 0, dest;
  vl pri;
  while (t < T) {
    while (t<SKIP || (t<T && pri.empty())) {
      if (dsts[t] != 0) {
        pri.pb(dsts[t]);
        go[dsts[t]] = true;
      }
      ans.pb(-1);
      t++;
    }
    dest = pri[0];
    go[dest] = false;
    vl path(1,dest);
    int dep = depth[dest], now = dest;
    while (depth[now] > 0) {
      for (int next = 0; next < V; next++) {
        if (edges[now][next] != -1 && depth[next] == depth[now] - 1) {
          path.pb(next);
          go[next] = false;
          now = next;
          dep--;
          break;
        }
      }
    }

    vl n_pri;
    if (!pri.empty()) {
      rep(i,pri.size()) {
        if (go[pri[i]]) {
          n_pri.pb(pri[i]);
        }
      }
    }
    
    reverse(all(path));
    int node = 0, nt = t;
    REP(i,1,path.size()) {
      int next_node = path[i];
      rep(j,edges[node][next_node]) ans.pb(next_node+1);
      nt += edges[node][next_node];
      node = next_node;
    }
    reverse(all(path));
    node = dest;
    REP(i,1,path.size()) {
      int next_node = path[i];
      rep(j,edges[node][next_node]) ans.pb(next_node+1);
      nt += edges[node][next_node];
      node = next_node;
    }
    for (int i = t+1; i <= min(nt,T-1); i++) {
      if (dsts[i] != 0) {
        n_pri.pb(dsts[i]);
        go[dsts[i]] = true;
      }
    }
    pri = n_pri;
    t = nt;
  }

  int len = ans.size();
  if (len < T) {
    rep(i,T-len) cout << -1 << '\n';
    rep(i,len) cout << ans[i] << '\n';
  } else {
    rep(i,T) cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;

int INF = 100000000;

int main() {
	long long N, K;
	long long DEN = 1000000007;
	cin >> N >> K;
	vector<int> A(N, 0);
	//vector<int> B(2*N, 0);
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	int Bi, Bj;
	long long  count1 = 0;
	for(int i = 0; i < N; i++){
		Bi = A[i];
		for(int j = i + 1; j < N; j++){
			Bj = A[j];
			if(Bi > Bj){
				count1++;
			}
		}				
	}
	
	long long count2 = 0;
	for(int i = 1; i < N; i++){
		Bi = A[i];
		for(int j = 0; j < i; j++){
			Bj = A[j];
			if(Bi > Bj) {
				count2++;
			}
		}				
	}
	
	long long KK1 = K*(K + 1)/2 % DEN;
	long long KK2 = (K-1)*K/2 % DEN;
	
	/*
	
	long long KK1 = 0;
	for(int i = K; i >= 1; i--){
		KK1 += i;
	}
	
	long long KK2 = 0;
	for(int i = (K-1); i >= 1; i--){
		KK2 += i;
	}
	
	*/
	/*
	cout << KK1 <<" KK " <<KK2 << endl;
	cout << count1 << " count "<< count2 << endl;
	*/
	long long total = (count1*KK1 + count2*KK2) % DEN;
	
	cout << total << endl;
	
	/*
	cout << "A ";
	for(const auto & e:A) cout << e <<" ";
	cout << endl;
	
	cout << count1 << " "<< count2 << endl;

	*/

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void main(void){
  int A,B,C,K;
  int n=0;
  scanf("%d %d %d",&A,&B,&C);
  scanf("%d",&K);
  
  while(A>=B){
    B=B*2;
    n+=1;
  }
  while(B>=C){
    C=C*2;
    n+=1;
  }
  if(n<=K)
    puts("Yes");
  else 
    puts("No");
}

  

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


int main(void){
    int n, y;
    cin >> n >> y;
    
    y/= 1000;
    
    for (int a = 0; a <= 2000; a++){
        for (int b = 0; b <= 4000; b++){
            int c = n - a - b;
            if (0 <= c && 10*a + 5*b + c == y){
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
typedef long long ll;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
using namespace std;

int main()
{
    int n, a, count = 0;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    while (true)
    {
        vector<int> tmp(all(h));
        sort(all(tmp), greater<int>());
        a = tmp[0];
        if (a == 0)
            break;
        rep(i, n)
        {
            if (h[i] == a)
            {
                if (i == n - 1)
                {
                    count++;
                }
                else if (h[i + 1] != a)
                {
                    count++;
                }
                h[i] -= 1;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long l,r;
    cin>>l>>r;
    long long ans=2020;
    
    for(long long i=l;i<=r;i++){
        bool a=false;
        for(long long j=i;j<=r;j++){
            if(i==j) continue;
            ans=min((i*j)%2019,ans);
            if(ans==0){
                a=true;
                break;
            }
        }
        if(a) break;
    }
    
    cout<<ans<<endl;;
    
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

// 素数判定
bool isPrime(ll n) {
    ll i = 2;
    while (i*i <= n) {
        if(n%i==0) return false;
        i++;
    }
    return true;
}


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

    ll ans = 0;
    while(n > 0) {
        n /= k;
        ans += 1;
    }
    if(n%k > 0) ans++;
    cout << ans << endl;
    return 0;
}


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

#define POS(i,j) ((i)*c+(j))

void run(void){
  int n,c;
  scanf("%d%d",&n,&c);
  int *d=(int *)malloc(sizeof(int)*c*c);
  int i,j;
  for(i=0;i<c*c;i++) scanf("%d",d+i);
  int *cnt=(int *)calloc(3*c,sizeof(int));
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      int m;
      scanf("%d",&m);
      m--;
      cnt[POS((i+j)%3,m)]++;
    }
  }
  int min=1000*n*n;
  int x,y,z;
  for(x=0;x<c;x++){
    for(y=0;y<c;y++){
      for(z=0;z<c;z++){
	if(x==y || y==z || z==x) continue;
	int sum=0;
	for(i=0;i<c;i++){
	  sum+=cnt[POS(0,i)]*d[POS(i,x)];
	  sum+=cnt[POS(1,i)]*d[POS(i,y)];
	  sum+=cnt[POS(2,i)]*d[POS(i,z)];
	}
	if(min>sum) min=sum;
      }
    }
  }
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
  print(0)
  exit()

X.sort()
sa = []
for i in range(M-1):
  sa.append(X[i+1]-X[i])

sa.sort(reverse=True)

print(sum(sa[N-1:]))



Measured memory_bytes: 13968
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    stdin.read_until(b'\n', &mut Vec::new()).unwrap();
    let res = stdin.split(b' ')
        .map(|r| {
            String::from_utf8(r.unwrap()).unwrap()
                .trim_right()
                .parse::<u32>().unwrap()
                .trailing_zeros()
        })
        .min()
        .unwrap();
    println!("{}", res);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    long n;

    cin >> n;

    ll a[n];
    ll ans = 0;

    long i;
    ll j, k, l;

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

    sort(a, a + n);

    l = 0;
    k = n;
    rep(i, n) {
        repi(j, a[i], l) ans ^= k;

        l = a[i];
        k--;
    }

    if (ans == 0) Out("second");
    else Out("first");

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
 
int main(){

    int n;cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
    	ll x = n / i;
    	ans += x * (x + 1) * i / 2;
    }
    cout<<ans;

    return 0;
}

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

#define PI 3.1415926535897

int main()
{
  int a, b, C;
  double S, L, h, d, HL;

  scanf("%d %d %d", &a, &b, &C);

  d=sqrt(a*a+b*b-2*a*b*cos(C*PI/180));
  L=a+b+d;

  HL=L*0.5;
  S=sqrt(HL*(HL-a)*(HL-b)*(HL-d));

  h=2*S/a;

  printf("%f\n%f\n%f\n", S, L, h);  
  return 0;

}

Measured memory_bytes: 660
function main(input) {
  const inputs = input.split('\n')
  const [S] = inputs[0].split(' ')
  console.log(S[2] === S[3] && S[4] === S[5] ?
   'Yes' : 'No'
  )

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
package main

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

func main() {
	N := nextInt()
	Hs := nextInts(N)
	fmt.Println(solve(Hs))
}

func solve(Hs []int) int {
	dp := make([]int, len(Hs))
	dp[0] = 0
	dp[1] = Abs(Hs[1] - Hs[0])
	for i := 2; i < len(Hs); i++ {
		c1 := dp[i-1] + Abs(Hs[i]-Hs[i-1])
		c2 := dp[i-2] + Abs(Hs[i]-Hs[i-2])
		dp[i] = Min(c1, c2)
	}
	return dp[len(Hs)-1]
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

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

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

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

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


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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 2e9;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  string s;
  cin >> n >> s;

  vi suffcntr(n);
  for (int i=n-2; i>=0; --i)
    suffcntr[i] = suffcntr[i+1] + (s[i+1] == 'R' ? 1 : 0);

  vi suffcntg(n);
  for (int i=n-2; i>=0; --i)
    suffcntg[i] = suffcntg[i+1] + (s[i+1] == 'G' ? 1 : 0);

  vi suffcntb(n);
  for (int i=n-2; i>=0; --i)
    suffcntb[i] = suffcntb[i+1] + (s[i+1] == 'B' ? 1 : 0);

  int cnt = 0;
  for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      if (s[i] == s[j])
        continue;
      char target;
      if (s[i] == 'R' && s[j] == 'G')
        target = 'B';
      else if (s[i] == 'R' && s[j] == 'B')
        target = 'G';
      else if (s[i] == 'G' && s[j] == 'R')
        target = 'B';
      else if (s[i] == 'G' && s[j] == 'B')
        target = 'R';
      else if (s[i] == 'B' && s[j] == 'R')
        target = 'G';
      else if (s[i] == 'B' && s[j] == 'G')
        target = 'R';
      else
        assert(false);

      if (target == 'R')
        cnt += suffcntr[j];
      if (target == 'G')
        cnt += suffcntg[j];
      if (target == 'B')
        cnt += suffcntb[j];
      int off = j-i;
      if (j+off < n && s[j+off] == target)
        --cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3712
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	_= scanNums()
	heights := scanNums()


	ans :=0
	max := 0

	for _, h :=  range heights{
		if h >= max{
			ans += 1
			max = h
		}
	}

	fmt.Println(ans)

}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, N)cin >> A[i];
    rep(i, N)cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());

    ll out = -1, safe = 1ll << 60;
    while (safe - out > 1) {
        ll mid = (out + safe) / 2;
        ll cost = 0;
        rep(i, N) {
            ll needA = mid / F[i];
            cost += max(0ll, A[i] - needA);
        }
        (cost <= K ? safe : out) = mid;
    }
    cout << safe << endl;
    return 0;
}


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

typedef long long ll;
const ll M = 1872000;

//            1  2  3  4  5  6  7  8  9 10 11 12
int h[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
 
bool is_leap(int y){
	return ((y % 400 == 0) || (y % 4 == 0 && y % 100 != 0));
}
 
struct Time{
	int y, m, d;
	Time(int y_, int m_, int d_){
		y = y_; m = m_; d = d_;
	}
	Time operator++(){
		if( is_leap( y ) && m == 2 && d == 28 ){
			d++;
		}else if(is_leap( y ) && m == 2 && d == 29 ){
			m++;
			d = 1;
		}else{
			if( d < h[m-1] ){
				d++;
			}else{
				d = 1;
				if( m == 12 ){
					m = 1;
					y++;
				}else{
					m++;
				}
			}
		}
	}
};

ll get_day(ll y, ll m, ll d){
	if( m <= 2 ) y--, m += 12;
	ll dy = 365 * (y - 1);
	ll c = y / 100;
	ll dl = (y >> 2) - c + (c >> 2);
	ll dm = (m * 979 - 1033) >> 5;
	return dy + dl + dm + d - 1;
}

int main(){
	string s;
	int b, ka, t, w, ki, y, m, d;
	ll ss = get_day(2012, 12, 21);
	
	while( cin >> s ){
		if( s == "#" ) break;
		
		int cnt = 0;
		for(int i = 0 ; i < s.size() ; i++ ){
			if( s[i] == '.' ) cnt++;
			else s[i] -= '0';
		}
		
		if( cnt == 2 ){ // 西暦のとき
			int c[3] = {0}, k = 0;
			for(int i=0 ; i < s.size() ; i++ ){
				if( s[i] == '.' ){
					k++;
				}else{
					c[k] = c[k] * 10 + s[i];
				}
			}
			y = c[0], m = c[1], d = c[2];
			ll day = (get_day(y, m, d) - ss) % M;
			ki = day % 20;
			day /= 20;
			w = day % 18;
			day /= 18;
			t = day % 20;
			day /= 20;
			ka = day % 20;
			day /= 20;
			b = day % 13;
			printf("%d.%d.%d.%d.%d\n", b, ka, t, w, ki);
		}else{ // マヤ暦のとき
			int c[5] = {0}, k = 0;
			for(int i=0 ; i < s.size() ; i++ ){
				if( s[i] == '.' ){
					k++;
				}else{
					c[k] = c[k] * 10 + s[i];
				}
			}
			b = c[0], ka = c[1], t = c[2], w = c[3], ki = c[4];
			ll day = b * 20 * 20 * 18 * 20 + ka * 20 * 18 * 20 + t * 18 * 20 + w * 20 + ki;
			y = 2012, m = 12, d = 21;
			while( day >= 365 ){
				if( is_leap(y+1) ){
					if( day - 366 >= 0 ){
						day -= 366;
						y++;
					}
				}else{
					if( day - 365 >= 0 ){
						day -= 365;
						y++;
					}
				}
			}
			Time t(y, m, d);
			while( day ){
				++t;
				day--;
			}
			printf("%d.%d.%d\n", t.y, t.m, t.d);
		}
	}
}

Measured memory_bytes: 1192
#include<stdio.h>
int main() {
    int a[100003];
    int i = 0;
    int temp;
   
    do{

        scanf("%d", &temp);
        a[i] = temp;
        i++;
    } while (temp != 0);
    for (int j = 0; j < i-1; j++)
        printf("Case %d: %d\n", j+1, a[j]);

        return 0;
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
using namespace std;
int x[200000],y[200000],dp[200000];
signed main(){
	int n;
	cin>>n;
	f(i,200000) y[i]=-1;
	dp[0]=1;
	f(i,n){
		cin>>x[i];
		if(y[x[i]-1]>=0&&i-y[x[i]-1]>1)dp[i]+=dp[y[x[i]-1]];
		y[x[i]-1]=i;
		if(i) dp[i]+=dp[i-1];
		dp[i]%=1000000007;
	}
	cout<<dp[n-1]<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    vector<int> snum(S.size());
    for(int i=0;i<S.size();i++){
        if(S[i]=='A'||S[i]=='G'||S[i]=='C'||S[i]=='T'){
            snum[i]=1;
        }
        else snum[i]=0;
    }
    int ma=0;
    int tmp=0;
    int tmpma=0;
    for(int i=0;i<S.size();i++){
        if(snum[i]==1) tmp++;
        else tmp=0;
        ma=max(ma,tmp);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n,k;
    string s;
    cin >> n >> k >> s;
    s.push_back('2');
    vector<ll> c(0);
    if(s[0] == '0')c.push_back(0);
    ll cnt = 1;
    rep0(i, n){
        if(s[i] != s[i + 1]){
            c.push_back(cnt);
            cnt = 1;
        }else ++cnt;
    }
    if(s[s.size() - 2] == '0')c.push_back(0);
    rep0(i, c.size() - 1)c[i + 1] += c[i];
    ll ans = 0;
    rep0(i, max(ll(c.size() - k * 2),1ll)){
        if(i + k * 2 < c.size())chmax(ans, c[i + k * 2] - (i > 0? c[i - 1]:0));
        else chmax(ans, c[c.size() - 1]);
        ++i;
    }
    pf(ans);
    return 0;
}


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

ll INF = 1e13;

struct Edge{
    /*辺の情報を入れる構造体で行き先とコストを表している*/
    int to;
    ll cost;
    Edge(int to, ll cost) : to(to), cost(cost) {}
};

struct unionfind{
    vector<int> d;
    unionfind(int n=0) : d(n, -1){}
    int find(int x) {//根を返す関数
        if(d[x]<0) return x;
        return d[x]=find(d[x]);//d[x]にfind[d[x]]の値を代入してそれを返している．これにより根に全ての子を繋げられる．
    }
    bool unite(int x, int y){
        x=find(x);y=find(y);
        if(x == y) return false;
        if(d[x]>d[y]) swap(x, y);//-なので逆にしている
        d[x]+=d[y];//連結成分サイズを保持している
        d[y]=x;//yの根をxにしている
        return true;
    }
    bool same(int x, int y){return find(x)==find(y);}//同じかどうかを判定
    int size(int x){return -d[find(x)];}//連結成分の数を返す
    vector<int>kind(){
        vector<int> res;
        rep(i, d.size()){
            if(d[i]<0) res.push_back(i);
        }
        return res;
    }
};


vector<ll> dist;
vector<Edge>g[200005];
int k;
bool ok;
void dfs(int u, int now){
    /*rep(i, dist.size()) {
        cout<<dist[i]<<" ";
    }
    cout<<endl;*/
    for(auto v : g[u]){
        if(dist[v.to] == INF){
            dist[v.to] = dist[u]+v.cost;
            now++;
            dfs(v.to, now);
        }
        else {
            if(dist[v.to] != dist[u]+v.cost){
                ok = false;
                return;
            }
        }
    }
}

int main(void){
    int n, m;
    cin>>n>>m;
    unionfind uf(n);
    rep(i, m){
        int l, r;
        ll d;
        cin>>l>>r>>d;
        --l;--r;
        g[l].push_back(Edge(r, d));
        g[r].push_back(Edge(l, -d));
        uf.unite(l, r);
    }
    vector<int> kind = uf.kind();
    dist.resize(n);
    rep(i, n){
        dist[i] = INF;
    }
    rep(i, kind.size()){
        dist[kind[i]] = 0;
        ok = true;
        k = uf.size(kind[i]);
        dfs(kind[i], 0);
        if(!ok){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<ll> A;
string S;
signed main(){
    cin >> S;
    for(int i=0;i<3;i++) {
        if(S[i]=='R') tmp++;
        else tmp=0;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

ll mod=1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> p;
    vector<int> pc;
    ll ans=1;
    for (int i=2;i<=n;i++) {
        int j=i;
        while (j>1) {
            for (int k=0;k<p.size();k++) {
                while (j%p[k]==0) {
                    pc[k]++;
                    j/=p[k];
                }
            }
            if (j>1) {
                p.push_back(j);
                pc.push_back(1);
                j=1;
            }
        }
    }
    for (int i=0;i<p.size();i++) {
        ans*=pc[i]+1;
        ans=ans%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}

string s,t;
int memo[3005][3005];
int32_t main()
{
  desperate_optimization(true);
  cin>>s>>t;
  for(int i=s.size();i>=0;i--)
  {
    for(int j=t.size();j>=0;j--)
    {
      if(i==s.size()||j==t.size()) {memo[i][j]=0; continue;}
      if(s[i]==t[j]) memo[i][j]=memo[i+1][j+1]+1;
      memo[i][j]=max(memo[i][j],memo[i+1][j]);
      memo[i][j]=max(memo[i][j],memo[i][j+1]);
    }
  }
  string result="";
  int i=0,j=0;
  while(true)
  {
    if(i==s.size()||j==t.size()) break;
    if(s[i]==t[j]) {result+=s[i]; i++; j++; continue;}
    if(memo[i][j+1]>memo[i+1][j])
    {
      j++;
      continue;
    }
    i++;
  }
  cout<<result;


  // cout<<dpfunction(0,0).second;

  return 0;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n , m;
    cin >> n >> m;
    vector<bool> acc(n);
    vi cnt(n);
    ll ans = 0 , sum = 0;
    int p;
    string s;
    loop(i,m){
        cin >> p >> s;
        p--;
        if(s[0] == 'A'){
            if(!acc[p]){
                acc[p] = true;
                ans++;
                sum += cnt[p];
            }
        }else{
            cnt[p]++;
        }
    }

    cout << ans << " " << sum << endl;


    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<pair<int, pii>> ab;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    ab.eb(mp(a + b, mp(a, b)));
  }
  sort(rall(ab));
  ll ans = 0;
  rep(i, n) {
    if (i % 2)
      ans -= ab[i].S.S;
    else
      ans += ab[i].S.F;
  }
  cout << ans << endl;
}


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

namespace program{
    public class AtCoder{
        public static void Main(string[] args){
            // 整数の入力
    		int K = int.Parse(Console.ReadLine());
    		// スペース区切りの整数の入力
    		string[] input = Console.ReadLine().Split(' ');
    		int A = int.Parse(input[0]);
    		int B = int.Parse(input[1]);
    		int bai = B / K;
    		if(K * bai >= A){
    		    //出力
    		    Console.WriteLine("OK");
    		}else{
    		    //出力
    		    Console.WriteLine("NG");
    		}
    		
        }
    }
}


Measured memory_bytes: 17844
#include<stdio.h>
int main(void) {
	int r, g, b;
	scanf("%d %d %d", &r, &g, &b);
	int a = 100 * r + 10 * g + 1 * b;

	if (a % 4 == 0) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> lol(n);
	for (int i = 0; i < n; i++) {
		cin >> lol[i];
	}
	sort(lol.begin(), lol.end());
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += lol[i];
	}
	cout << sum;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>;

ll n;
Graph G;
vector<ll> ans;

void dfs(ll v, ll p, ll c) {
    ans[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second % 2 == 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> n;
    G.assign(n, vector<Edge>());

    rep(i, 0, n-1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].emplace_back(Edge(v, w));
        G[v].emplace_back(Edge(u, w));
    }

    ans.assign(n, 0);
    dfs(0, -1, 1);
    for (auto v : ans) cout << v << endl;
}

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


int main()
{
  int n,m;
  cin >> n >> m;
  cout << m * (m-1) / 2 + n * (n-1) / 2 << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    int n = h + w;
    vector<string> g(h);
    for(int i = 0; i < h; i++)cin >> g[i];
    int ans = 0;

    for(int bit = 0; bit < (1<<n); bit++) {

        vector<string> s = g;
        //横
        for(int i = 0; i < h; i++) {
            if((1<<i) & bit) {
                for(int j = 0; j < w; j++) s[i][j] = '!';
            }
        }

        //縦
        for(int i = 0; i < w; i++) {
            if((1<<(h + i)) & bit) {
                for(int j = 0; j < h; j++)s[j][i] = '!';
            }
        }
        int cnt = 0;
        for(int i = 0; i < h; i++)cnt += count(s[i].begin(), s[i].end(), '#');
        if(cnt == k)ans++;

        
        //print(s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 100005;
template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------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
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}
string str;
int n;
ll dp[mx][10][13];
ll call(int pos,int val,int rem)
{
    //cout<<pos<<' '<<val<<' '<<rem<<endl;
    if(pos==n) return (rem==5);
    ll &ret = dp[pos][val][rem];
    if(ret!=-1) return ret;
    ret=0;
    if(str[pos]!='?')
    {
        int u=str[pos]-'0';
        rem=(rem*10+u)%13;
        ret=(ret+call(pos+1,u,rem))%mod;
    }
    else
    {
        for(int i=0;i<10;i++)
        {
            int ram=(rem*10+i)%13;
            ret=(ret+call(pos+1,i,ram))%mod;
        }
    }
    //D(dp[pos][val][rem]);
    return ret;
}
int main()
{

    cin>>str;
    n=str.size();
    mem(dp,-1);
    cout<<call(0,0,0)<<endl;
}


Measured memory_bytes: 111568
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt();
		int A[]=new int[n];
		boolean ans[]=new boolean[20*2000+1];
		for(int i=0;i<n;i++){
			A[i]=stdIn.nextInt();
		}
		for(int i=0;i<Math.pow(2,n);i++){
			int cout=0;
			for(int j=0;j<n;j++){
				  if((1&i>>j)==1)
					  cout+=A[j];
			}
			ans[cout]=true;
		}
		int q=stdIn.nextInt();
		for(int i=0;i<q;i++){
			int m=stdIn.nextInt();
			if(ans[m])
				System.out.println("yes");
			else
				System.out.println("no");
		}
	}
}



Measured memory_bytes: 27224
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        long h=sc.nextLong();
     
        out.println(rep(h));
     	out.flush();
    }
    
    static long rep(long h) {
    	if(h==0)return 0;
    	return 1+rep(h/2)*2;
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int x,y;
    P(int x,int y) {
    	this.x=x;
    	this.y=y;
    }

    public int compareTo(P p){
        return y-p.y;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23252
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
	#include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
	#define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
	#define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
	#define debug(x...)
	#define light_debug(x) 
#endif

#define int ll

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int MOD = 1000000007;

int modpow(int a, int n){
	while(n < 0) n += MOD - 1;
	ll v = 1;
	for(int i = 31; i >= 0; i--){
		(v *= v) %= MOD;
		if(n & (1 << i))
			(v *= a) %= MOD;
	}
	return (int)v;
}

ll fact[500005], ifact[500005];

void init(){
	fact[0] = ifact[0] = 1;
	rep1(i, 500000)
		fact[i] = fact[i - 1] * i % MOD, ifact[i] = ifact[i - 1] * modpow(i, -1) % MOD;
}

inline int nCr(int n, int r){
	return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}

inline int nPr(int n, int r){
	return fact[n] * ifact[n - r] % MOD;
}


signed main(){

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

	#ifdef DEBUG
		freopen("debug", "w", stderr);
	#endif

	init();
	ll N, M;
	cin >> N >> M;
	
	ll ans = nPr(M, N);
	rep1(i, N){
		ll k = nCr(N, i) * nPr(M - i, N - i) % MOD;
		if(i & 1)
			(ans += MOD - k) %= MOD;
		else
			(ans += k) %= MOD;
	}

	debug(ans);
	(ans *= nPr(M, N)) %= MOD;

	cout << ans << '\n';

	#ifdef DEBUG
		dbg::dout << "\nExecution time: " << clock() << "ms\n";
	#endif

	return 0;
}
	

Measured memory_bytes: 11436
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n,d,x; cin >> n >> d >> x;
  ll ans = x;
  REP(i, n){
    ll a; cin >> a;
    for(ll j=0; 1+j*a<=d; j++) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

N = int(input())
a = list(map(int,input().split()))
b = [0] * N

for i in reversed(range(N)):
    x = math.floor(N/(i+1))
    temp = 0
    for k in range(1,x+1):
        temp += b[k*(i+1) - 1]
    if a[i] != (temp%2):
        b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1), end = " ")


Measured memory_bytes: 7276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Calculate(int N, int[] P)
        {
            int d = 1;
            for (int i = 2; i <= N; ++i) { d *= i; }
            var list = new List<int>(Enumerable.Range(1, N));
            int ans = 0;
            for (int i = 0; i < N; ++i)
            {
                d /= N - i;
                for (int j = 0; j < list.Count; ++j)
                {
                    if (P[i] == list[j])
                    {
                        ans += j * d;
                        list.RemoveAt(j);
                        break;
                    }
                }
            }
            return ans;
        }

        static int Solve(int N, int[] P, int[] Q)
        {
            return Math.Abs(Calculate(N, P) - Calculate(N, Q));
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] P = ReadInts();
            int[] Q = ReadInts();
            Console.WriteLine(Solve(N, P, Q));
        }
    }
}


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

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

Measured memory_bytes: 3588