akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n,k; cin>>n>>k;
ll a[n]={};
rep(i,n) cin>>a[i];
for(ll i=0; i<n-k; i++){
if(a[i]<a[i+k]){
cout << "Yes" << endl;}
else cout << "No" << endl;}}

Measured memory_bytes: 5200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	string S,T;
	cin >> S >> T;
	char A;
	bool B = false;
	for(int i = 0;i < S.size();i++) {
		A = S.at(S.size() - 1);
		for(int j = S.size() - 1;j >= 0;j--) {
			if(j == 0) {
				S.at(j) = A;
			}
          else {
				S.at(j) = S.at(j - 1);
          }
		}
		if(S == T) {
			B = true;
		}
	}
	if(B == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n, m, c = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)
as = []
n.times do
  as << gets.split.map(&:to_i)
end
ans = 0
for i in 0..(n-1) do
  temp = c
  aa = as[i]
  for j in 0..(m-1) do
    temp += aa[j] * bs[j]
  end
  ans += 1 if temp > 0
end
puts ans

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n; cin >> n;
  if(n >= 30) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

long long int MOD = 1e9 + 7 ;
long long int arr[300005] ;

long long int sumXOR(int n)
{
	long long int sum = 0;
	for (int i = 0; i < 64; i++)
	{
		int zc = 0, oc = 0;

		long long int idsum = 0, idsumX, idsumY, idsumZ;
		for (int j = 0; j < n; j++)
		{
			if (arr[j] % 2 == 0)
				zc++;
			else
				oc++;
			arr[j] /= 2;
		}

		idsum = ( (((oc%MOD) * (zc%MOD)) % MOD) * (((1%MOD) << (i%MOD))%MOD) ) % MOD;

		sum = ((sum%MOD) + (idsum%MOD))%MOD;
	}
	return sum;
}

int main()
{
	long long int sum = 0;
	long long int n, ans;
	cin >> n ;
	for(int i = 0; i < n; i++)  cin >> arr[i] ;
  ans = sumXOR(n) % MOD ;
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 2560
<?php

fscanf(STDIN, '%d', $n);
if ($n < 2) {
    echo "1\n";
    die;
}

$prev1 = 1;
$prev2 = 1;
$result = 0;
for ($i = 2; $i <= $n; $i++) {
    $result = $prev1 + $prev2;
    $prev2 = $prev1;
    $prev1 = $result;
}

echo $result, PHP_EOL;

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if((b-a) == (c-b)){
    printf("YES\n");
  }
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int MOD=1000000007;
	int n,k;
	cin>>n>>k;
	vi in(n);
	rep(i,n)cin>>in[i];
	int t=0;
	rep(i,n){
		int c1=0,c2=0;
		rep(j,n)if(in[j]<in[i])c1++;
		rep(j,n)if(in[j]<in[i]&&i<j)c2++;
		(t+=k*(k-1)/2%MOD*c1%MOD)%=MOD;
		(t+=c2*k%MOD)%=MOD;
	}
	cout<<t<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main()
{
  long x;
  cin >> x;
  long f;
  long i,j;
  for(i = 0;i<125;++i){
    f = i*i*i*i*i-x; 
    for(j = -124;j<124;++j){
      if(j*j*j*j*j==f) goto find;
    }
  }
  find:

  cout << i << " " << j << endl;
}


Measured memory_bytes: 3588
package main

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

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

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	defer out.Flush()

	a := next()
	if a[0] >= 65 && a[0] <= 90 {
		fmt.Fprintf(out, "A\n")
	} else if a[0] >= 97 && a[0] <= 122 {
		fmt.Fprintf(out, "a\n")
	}
}

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


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

const int N = 1e5 + 3;
const ll INF = 1e9 + 5;
vector<ll> dp(N, INF);

ll frog_2(int n, int k, ll ht[])
{
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<=i+k; j++)
        if(j < n)
            dp[j] = min(dp[j], (dp[i] + abs(ht[j] - ht[i])));
    }

    return dp[n-1];
}

int main()
{
    int n, k;
    cin >> n >> k;
    ll arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];

    cout << frog_2(n, k, arr);
}

Measured memory_bytes: 4816
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int[] n=new int[3];
    for(int i=0;i<3;i++){
      n[i]=sc.nextInt();
    }
    
    if(n[1]-n[0]==n[2]-n[1]){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

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

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

struct SegTree {
  ll n;
  vector<ll> v;

  SegTree(int size) {
    n = 1;
    while (n < size) n *= 2;
    v = vector<ll>(2 * n - 1);
  }

  void add(int i, ll x) {
    i += n - 1;
    v[i] += x;
    while (i > 0) {
      i = (i - 1) / 2;
      v[i] = v[2 * i + 1] + v[2 * i + 2];
    }
  }

  ll query(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return v[k];
    ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
    ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return c1 + c2;
  }

  ll query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<P> w(n);
  rep(i, n) cin >> w[i].first >> w[i].second;

  sort(w.begin(), w.end());
  ll ans = 0;
  ll sum = 0;
  priority_queue<P> pq;
  rep(i, n) {
    ll x = w[i].first;
    ll h = w[i].second;
    while (!pq.empty() && -pq.top().first < x) {
      sum -= pq.top().second;
      pq.pop();
    }
    h -= sum;
    h = max(0ll, h);
    int cnt = (h + a - 1) / a;
    ans += cnt;

    ll dmg = (ll)a * cnt;
    sum += dmg;
    pq.push({-(x + (ll)2 * d), dmg});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10564
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		Long[] p = new Long[a];
		for(int i = 0; i < a; i++){
		    p[i] = sc.nextLong();
		}
		Long[] q = new Long[b];
		for(int i = 0; i < b; i++){
		    q[i] = sc.nextLong();
		}
		Long[] r = new Long[c];
		for(int i = 0; i < c; i++){
		    r[i] = sc.nextLong();
		}
		
		Arrays.sort(p, Comparator.reverseOrder());
		Arrays.sort(q, Comparator.reverseOrder());
		Arrays.sort(r, Comparator.reverseOrder());
		
		// 計算
		long result = 0;
		PriorityQueue<Long> pq = new PriorityQueue<Long>();
		for(int i = 0; i < x; i++){
		    result += p[i];
		    pq.add(p[i]);
		}
		for(int i = 0; i < y; i++){
		    result += q[i];
		    pq.add(q[i]);
		}
		//int pcnt = x-1;
		//int qcnt = y-1;
		for(int i = 0; i < c; i++){
		    if(pq.isEmpty()) break;
		    long now = pq.poll();
		    if(now <= r[i]){
		        result -= now;
		        result += r[i];
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 104212
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    c = min(a[i],b[i])
    ans += c
    if a[i] < b[i]:
        ans += min(a[i+1],b[i]-a[i])
        a[i+1] = max(a[i+1] - (b[i]-a[i]),0)
        
print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll read(){
  ll a;
  cin>>a;
  return a;
}
int main(){
  ll n;
  cin>>n;
  bool f=true;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(a%2==0&&!(a%3==0||a%5==0)) f=false;
  }
  cout<<(f?"APPROVED":"DENIED")<<endl;
}


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

int main(){
    int N;cin>>N;
    int count=0;
    for(int i=0,p;i<N;i++){
        cin>>p;
        if(p%2)count++;
    }
    if(count%2)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import math as m

ls = input().split(" ")
n = int(ls[0])
d = int(ls[1])
Xs = []
ans = 0

for i in range(n):
	ls = input().split(" ")
	Xs.append([int(i) for i in ls])

for i in range(n - 1):
	for j in range(i + 1, n):
		if m.sqrt(sum([(a - b)**2 for a, b in zip(Xs[i], Xs[j])])).is_integer():
			ans += 1

print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

vector<int> primes;

bool isPrime(int p) {
  for (int i = 0; i < primes.size() && primes[i] <= sqrt(p); i++) {
    if (p % primes[i] == 0) {
      return false;
    }
  }
  return true;
}

void makePrimes(int n) {
  primes.pb(2);
  for (int i = 3; i <= n; i += 2) {
    if (isPrime(i)) {
      primes.pb(i);
    }
  }
}

int main() {
  makePrimes(1299709);
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < 100000; i++) {
      if (primes[i] == n) {
        cout << "0" << el;
        break;
      } else if (primes[i] > n) {
        cout << primes[i] - primes[i-1] << el;
        break;
      }
    }
  }
}

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

string invA( string s ){
	string ret;
	for(int i = s.length() - 1; i >= 0; i--)
		ret += s[i];
	return ret;
}
string invE( string s ) {
	int size = s.length();
	string ret;

	string div[3];
	div[0] = s.substr(0, size/2);
	div[1] = s.substr(size/2, size%2);
	div[2] = s.substr(size/2 + size % 2, string::npos);

	ret += div[2];
	ret += div[1];
	ret += div[0];

	return ret;
}
string invJ( string s ){
	int size = s.length();
	string ret;
	ret += s[size - 1]; 
	for(int i = 0; i < size - 1; i++)
		ret += s[i];
	return ret;
}
string invC( string s ){
	int size = s.length();
	string ret;
	for(int i = 1; i < size; i++)
		ret += s[i];
	ret += s[0];
	return ret;
}
string invM( string s ){
	int size = s.length();
	string ret;
	for(int i = 0; i < size; i++){
		if( s[i] < '0' || s[i] > '9' ) {
			ret += s[i];
		} else {
			if( s[i] == '9' ) {
				ret += '0';
			} else {
				ret += s[i] + 1;
			}
		}
	}
	return ret;
}
string invP( string s ){
	int size = s.length();
	string ret;
	for(int i = 0; i < size; i++){
		if( s[i] < '0' || s[i] > '9' ) {
			ret += s[i];
		} else {
			if( s[i] == '0' ) {
				ret += '9';
			} else {
				ret += s[i] - 1;
			}
		}
	}
	return ret;
}
string inv(string s, string o) {
	string ret;
	ret = s;
	for(int i = o.length() - 1; i >= 0; i--) {
		switch( o[i] ) {
		case 'A':
			ret = invA(ret);
			break;
		case 'E':
			ret = invE(ret);
			break;
		case 'J':
			ret = invJ(ret);
			break;
		case 'C':
			ret = invC(ret);
			break;
		case 'M':
			ret = invM(ret);
			break;
		case 'P':
			ret = invP(ret);
			break;
		}
	}
	return ret;
}
 
int main(void){
    //FILE* fp_in = freopen("data.txt", "r", stdin);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {
		string s,o;
		cin >> o;
		cin >> s;
		cout << inv(s, o) << endl;
	}
 
   //while(1){}
 
   return 0;
}

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

using namespace std;

int main() {
  int l, r;
  cin >> l >> r;

  if (r - l >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 2020;
  for (int i = l; i <= r; ++i) {
    for (int j = i + 1; j <= r; ++j) {
      ans = min(ans, (i % 2019) * (j % 2019) % 2019);
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import copy

h, w, s = map(int, input().split())
li = [list(input()) for _ in range(h)]
ans = 0

for i in range(h):
    for j in range(w):
        if li[i][j] == '#':
            li[i][j] = 1
        else:
            li[i][j] = 0

cnt = 0

for i in range(2 ** h):
    for j in range(2 ** w):
        swicth1 = [0]*h
        swicth2 = [0]*w
        
        for k in range(h):
            for l in range(w):
                if ((i >> k) & 1):
                    swicth1[h - 1 - k] = 1

                if ((j >> l) & 1):
                    swicth2[w - 1 - l] = 1
        tmp = copy.deepcopy(li)
        
        for x in range(h):
            for y in range(w):
                if swicth1[x] == 1 or swicth2[y] == 1:
                    tmp[x][y] = 0
        cnt = 0
        for x in range(h):
            cnt += sum(tmp[x])
        
        if cnt == s:
            ans += 1
                
print(ans)

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll a, ll b){
	if(b==0) return 1LL;
	if(b==1) return a;
	if(b%2==0) return POW(a*a%INF,b/2);
	return a*POW(a,b-1)%INF;
}

int main(){
	int n;
	ll k;
	ll ans = 0;
	cin >> n >> k;
	int a[n];
	REP(i, n) cin >> a[i];
	REP(i, n){
		REP(j, n){
			if(a[i] > a[j]){
				if(i < j) ans += (k*(k+1)/2)%INF;
				else ans += (k*(k-1)/2)%INF;
			}
		}
	}
	ans %= INF;
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=c && b<=c){
		if(a<=b){
			printf("%d %d %d\n",a,b,c);
		}
		else{
			printf("%d %d %d\n",b,a,c);
		}
	}
	else if(a<=b&&c<=b){
		if(a<=c){
			printf("%d %d %d\n",a,c,b);
		}
		else{
			printf("%d %d %d\n",c,a,b);
		}
	}
	else{
		if(c<=b){
			printf("%d %d %d\n",c,b,a);
		}
		else{
			printf("%d %d %d\n",b,c,a);
		}
	}
	return 0;
}

Measured memory_bytes: 2696
#include <iostream>
#include <algorithm>
using namespace std;
int dp[111111],a[111111];
int main() {
	int n,k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[2] = abs(a[1] - a[2]);
	for (int i = 3; i <= n; i++) {
		int m = 1e9;
		for (int j = max(i - k,1); j < i; j++) {
			m = min(m, dp[j] + abs(a[i] - a[j]));
		}
		dp[i] = m;
	}
	cout << dp[n];
}

Measured memory_bytes: 4364
#include <stdio.h>

int main()
{
int a[4][13]={0};//これで全てゼロクリアされます
int i, j, k, x, n;
char m;

scanf("%d", &n);

for(k = 0; k < n; k++){
scanf(" %c%d", &m, &x);//先頭にスペースを入れておくと、スペースや改行をパスできる
if(m == 'S')
a[0][x - 1] = 1;
else if(m == 'H')
a[1][x - 1] = 1;
else if(m == 'C')
a[2][x - 1] = 1;
else if(m == 'D')
a[3][x - 1] = 1;
}
//printf("\n");

for(i = 0; i < 4; i++){
for(j = 0; j < 13; j++){
if(a[i][j] == 0){
if(i == 0)
printf("S %d\n", j + 1);
else if(i == 1)
printf("H %d\n", j + 1);
else if(i == 2)
printf("C %d\n", j + 1);
else if(i == 3)
printf("D %d\n", j + 1);
}
}
}
return 0;
}




Measured memory_bytes: 2104
n,k = map(int,input().split())
def kai(x):
    ans = 1
    for i in range(x):
        ans *= i+1
    return ans
def kc2(k):
    return int(kai(k) /(2*kai(k-2)))

n_1c2 = kc2(n-1)
#print(n_1c2)
if k > n_1c2:
    print(-1)
else:
    lis = []
    for i in range(1,n):
        lis.append([1,i+1])
    cnt = 2
    now = 2
    for j in range(1,n_1c2 - k +1):
        cnt += 1
        if cnt > n:
            now +=1
            cnt = now +1
        lis.append([now,cnt])
    print(len(lis))
    for u,v in lis:
        print(u,v)


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>x>>k>>d;
    if(x>0)
    {
        n=x/d;
        a=x-(min(k,n)*d);
        k-=min(k,n);
    }
    else
    {
        n=x/d;
        a=x+(min(k,abs(n))*abs(d));
        k-=min(k,abs(n));
    }
    if(k%2)cout<<min(abs(a-d),abs(a+d))<<endl;
    else cout<<abs(a)<<endl;
}



Measured memory_bytes: 3640
N = int(input())
p = [-1] + list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(i+1):
        if j == 0:
            dp[i][j] += dp[i-1][j] * (1-p[i])
        else:
            dp[i][j] += dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i])

print(sum([dp[N][j] for j in range(N+1) if j >= -(-N//2)]))

Measured memory_bytes: 262408
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }

inline ll Msq(ll x){ return (x*x) %MOD; }
inline ll Mpot(ll x, ll e){
	if(!e) return 1;
	return Msq(Mpot(x, e>>1)) * (e & 1 ? x : 1)%MOD;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 5e3+3;

vector<string> v;
string s;

int main(){
	int k;
	cin >> s >> k;
	int n=s.length();
	for(int i=0; i<n; i++){
		string t="";
		for(int j=i; j<min(n, i+6); j++){
			t = t + s[j];
			v.push_back(t);
		}
	}
	sort(all(v));
	unique(all(v));
	cout << v[k-1] << endl;
}


Measured memory_bytes: 1916
import math

(N,P) = map(int,input().split())

if N == 1:
    print(P)
    exit()

ans = 1
p = 2
logP = math.log(P)
while N * math.log(p) <= logP:
    k = 0
    while P % p == 0:
        P //= p
        k += 1
    ans *= p**(k//N)
    if k > 0:
        logP = math.log(P)

    r = p % 6
    if r == 1:
        p += 4
    elif r == 5:
        p += 2
    else:
        p += 1

print(ans)

Measured memory_bytes: 3064
def gusu(n):
    return n // 2
def kisu(n):
    return 3 * n + 1

s = int(input())
num = [s]
i = 2
while True:
    if(s % 2 == 0):
        j = gusu(s)
    else:
        j = kisu(s)
    if(j in num):
        break
    else:
        num.append(j)
        i += 1
        s = j
print(i)


Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[a[0]]
ans=0
for i in range(n):
  if c[i]>b[i]:
    ans+=b[i]
    c.append(a[i+1])
  elif c[i]+a[i+1]>b[i]:
    ans+=b[i]
    c.append(c[i]+a[i+1]-b[i])
  else:
    ans+=c[i]+a[i+1]
    c.append(0)
print(ans)


Measured memory_bytes: 19156
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int[] brr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            brr[i] = Integer.parseInt(st.nextToken());
         int[] crr = new int[N-1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N-1; i++)
            crr[i] = Integer.parseInt(st.nextToken());
         //
         int res = 0;
         for(int i=0; i < N; i++)
         {
            res += brr[arr[i]-1];
            if(i > 0 && arr[i-1]+1 == arr[i])
               res += crr[arr[i-1]-1];
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 22484
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
LL A,B;
LL t[1001];
int main(){
    cin>>N>>A>>B;
    LL ans=N;
    REP(i,N){
        cin>>t[i];
        if(A<=t[i]&&t[i]<B){
           ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

struct Rect {
  int h, w, diagonal;
  void norm() {
    diagonal = h*h+w*w;
  }
  bool operator< (const Rect &r) const {
    return diagonal != r.diagonal ? diagonal < r.diagonal : h < r.h;
  }
};

int main() {
  Rect r[150][150];

  for(int i=0; i<150; i++) {
    for(int j=0; j<150; j++) {
      r[i][j].h = i+1, r[i][j].w = j+1;
      r[i][j].norm();
    }
  }

  sort(r[0], r[0]+150*150);

  Rect rin;
  while(cin >> rin.h >> rin.w, rin.h+rin.w) {
    rin.norm();
    for(int i=0; i<150; i++) {
      for(int j=0; j<150; j++) {
	if(rin<r[i][j] && r[i][j].h < r[i][j].w) {
	  cout << r[i][j].h << ' ' << r[i][j].w << endl;
	  goto Fin;
	}
      }
    }
  Fin:;
  }
  
  return 0;
}

Measured memory_bytes: 1440
#include <iostream>
int main(){
	int S,h=0,m=0,s=0;
	std::cin >> S;
	s=S%60;
	m=S/60%60;
	h=S/3600;
	std::cout << h <<":"<< m << ":" << s << std::endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,m);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact,ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {
            fact[i+1] = fact[i]*(i+1) % M;
            ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;
        }
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;
        if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b] * ifact[b] % M;
        return tmp * fact[a] % M;
    }
};

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

    ll x,y;
    cin >> x >> y;
    
    ll a = (-x+2*y);
    ll b = (2*x-y);
    
    if(a >= 0 && a%3 == 0 && b >= 0 && b%3==0){
        a /= 3;
        b /= 3;
        
        combination C(a+b+1);
        cout << C.com(a+b,a) << endl;
        
    }else{
        cout << 0 << endl;
    }
    
    

    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    ll ac, wa, tle, re;
    ac = wa = tle = re = 0;

    cin >> n;
    rep(i, n) {
        string tmp;
        cin >> tmp;
        if (tmp == "AC") {
            ++ac;
        }
        else if (tmp == "WA") {
            ++wa;
        }
        else if (tmp == "TLE") {
            ++tle;
        }
        else if (tmp == "RE") {
            ++re;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define LL long long

const LL mod = 1000000007;
int n;
char s[5][55];
int vis[55];

int main()
{
    while(~scanf("%d", &n))
    {
        memset(vis, 0, sizeof(vis));
        for(int i = 0; i < 2; ++i)
            scanf("%s", s[i]);
        LL sum = 1;
        for(int i = 0; i < n; ++i)
        {
            if(i == 0)
            {
                if(s[0][i] == s[1][i]) sum *= 3;
                else
                {
                    sum *= 6;
                    i++;
                }
                sum %= mod;
            }
            else
            {
                if(s[0][i] == s[1][i])
                {
                    if(s[0][i - 1] == s[1][i - 1])
                    {
                        sum *= 2;
                        vis[i] = 1;
                    }
                    else sum *= 1;
                    sum %= mod;
                }
                else
                {
                    if(s[0][i - 1] == s[1][i - 1])
                    {
                        if(vis[i - 1]) sum *= 2;
                        else sum *= 2;
                    }
                    else sum *= 3;
                    sum %= mod;
                    i++;
                }
            }
        }
        printf("%lld\n", sum % mod);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
    int x;
    cin >> x;
    for(int i=x; x<1000000; i++) {
        if (IsPrime(i)) {
            cout << i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    vector<ll> w;
    for(ll i = 0; i < n; i++){
        if(s[i] == 'W') w.push_back(i);
    }
    for(ll i = 0; i < w.size(); i++) ans += w[i]-i;
    cout << ans << endl; 
}

Measured memory_bytes: 2552
#include<iostream>
using namespace std;
char s[10+2],t[10+2];
int n,a=0,ans=0;
bool c,d;

int main(){
	scanf("%s",&s);
	while(s[a]!='\0')a++;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s",&t);
		c=false;
		for(int j=0;j<10;j++){
			d=true;
			for(int k=0;k<a;k++){
				if(s[k]!=t[(j+k)%10])d=false;
			}
			if(d)c=true;
		}
		if(c)ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1176
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
#define int ll

signed main() {
	int dp[11][1010] = {};
	dp[0][0] = 1;
	rep(i, 0, 101)rrep(j, 0, 10)rep(k, 0, 1010 - i)
		dp[j + 1][k + i] += dp[j][k];
	for (int n, s; cin >> n >> s&&n;) {
		cout << dp[n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
import sys
import math

N = int(input())
S = []
F = []
C = []
for i in range(N-1):
    CSF = list(map(int,input().split()))
    C.append(int(CSF[0]))
    S.append(int(CSF[1]))
    F.append(int(CSF[2]))

for i in range(N):
    t = 0
    for j in range(i,N-1):
        t = max(S[j],math.ceil(t/F[j])*F[j])
        t += C[j]
    print(t)


Measured memory_bytes: 3188
fn input_with_space_singleline() -> Vec<i32>{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).expect("!");
    s.trim().split(" ").map(|ref x|x.parse::<i32>().unwrap()).collect::<Vec<i32>>()
}


pub fn main(){
    let N: usize = input_with_space_singleline()[0] as usize;
    let A = input_with_space_singleline();

    let mut accum = A[0];
    let mut xor = A[0];
    let mut r: usize = 1;
    let mut res = 0;
    for l in 0..(N as usize) {
        while r < N && accum + A[r] == xor ^A[r] {
            accum += A[r];
            xor ^= A[r];
            r += 1;
        }
        res += r - l;
        accum -= A[l];
        xor ^= A[l];
        if r == l {
            r += 1;
        }
    }
    println!("{}", res);
}

Measured memory_bytes: 8444
def main():
  s = input()
  divisor = 10 ** 9 + 7
  dp = [[0] * 13 for _ in range(len(s) + 1)]
  dp[0][0] = 1
  lut = [i % 13 for i in range(130)]
  list10 = list(range(10))
  for i in range(len(s)):
    dpi = dp[i]
    dpi1 = dp[i + 1]
    if s[i] == '?':
      j10 = 0
      for j in range(13):
        dpij = dpi[j]
        for k in list10:
          dpi1[lut[j10 + k]] += dpij
        j10 += 10
    else:
      t = int(s[i])
      for j in range(13):
        dpi1[lut[t]] += dpi[j]
        t += 10
    for k in range(13):
      dp[i + 1][k] %= divisor
  print(dp[len(s)][5])
main()


Measured memory_bytes: 62448
def nCr(n, r):
    ret = 1
    for i in range(1, n+1):
        ret *= i
    for i in range(1, r+1):
        ret //= i
    for i in range(1, n-r+1):
        ret //= i
    return ret

n, p = map(int, input().split())
a = map(int, input().split())
even, odd = 0, 0

for i in a:
  if i & 1:
    odd += 1
  else:
    even += 1

c_even = 2**even
c_odd = 0

start = 1 if p else 0

while start <= odd:
    c_odd += nCr(odd, start)
    start += 2

print(c_even * c_odd)

Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


int main(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    a--; b--; c--; d--;
    for(ll i=a;i<c;i++){
        if(s[i]=='#' && s[i+1]=='#'){cout<<"No"<<endl; return 0;}
    }
    for(ll i=b;i<d;i++){
        if(s[i]=='#' && s[i+1]=='#'){cout<<"No"<<endl; return 0;}
    }
    if(c<d){cout<<"Yes"<<endl; return 0;}
    for(ll i=b;i<=d;i++){
        if(s[i-1]=='.' && s[i+1]=='.' && s[i]=='.'){cout<<"Yes"<<endl; return 0;}
    }
    cout<<"No"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 888
n = int(input())
S = list(map(int, input().split()))

q = int(input())
T = list(map(int, input().split()))

ans = 0
for t in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == t:
            ans += 1
            break
        elif S[mid] > t:
            right = mid
        else:
            left = mid + 1
print(ans)


Measured memory_bytes: 16708
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s[0]=='S'&&s[1]=='U')
        cout<<7<<endl;
    else if(s[0]=='M'&&s[1]=='O')
        cout <<6<< endl;
    else if(s[0]=='T'&&s[1]=='U')
        cout <<5<< endl;
    else if(s[0]=='W'&&s[1]=='E')
        cout <<4<< endl;
    else if(s[0]=='T'&&s[1]=='H')
        cout <<3<< endl;
    else if(s[0]=='F'&&s[1]=='R')
        cout <<2<< endl;
    else
        cout <<1<< endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var Sd = ReadLine().Reverse().ToArray();
            var T = ReadLine().Reverse().ToArray();
            var N = Sd.Length;
            for (var i = 0; i < N - T.Length + 1; ++i)
            {
                var cdt = Sd.ToArray();
                var flg = true;
                for (var j = 0; j < T.Length; ++j)
                {
                    if (Sd[i + j] == T[j] || Sd[i + j] == '?')
                        cdt[i + j] = T[j];
                    else
                    {
                        flg = false;
                        break;
                    }
                }
                if (flg)
                {
                    cdt = cdt.Select(c => c == '?' ? 'a' : c).ToArray();
                    WriteLine(string.Join("", cdt.Reverse().ToArray()));
                    return;
                }
            }
            WriteLine("UNRESTORABLE");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26780
//============================================================================
// Name        : JOI.cpp
// Author      :2015 ho3
// Version     :???11:08
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<algorithm>
#include <queue>
using namespace std;

int N,Q;
long long X[200001]={};
int D[200001]={};
int L[200001]={};
const int INF=1000000001;
long long BX[300002];
long long BY[300002];
int N_MAX=18;

long long outBY(int n1){
	long long ans=0;
	int ps=0;
	for(int i=(1<<N_MAX);i>0;i=(i>>1)){
		if(n1>=i){
			ans+=BY[i+ps];
			n1-=i;
			ps+=i;
			if(n1==0)break;
		}
	}
	return ans;
}
long long outBX(int n1){
	long long ans=0;
	int ps=0;
	for(int i=(1<<N_MAX);i>0;i=(i>>1)){
		if(n1>=i){
			ans+=BX[i+ps];
			n1-=i;
			ps+=i;
			if(n1==0)break;
		}
	}
	return ans;

}
int inBX(int n1,int p){
	int ps=0;
	for(int i=(1<<N_MAX);i>0;i=(i>>1)){
		if(n1<=i)BX[i+ps]+=(long long)p;
		if(n1>=i){
			n1-=i;
			ps+=i;
			if(n1==0)break;
		}
	}
	return 0;
}
int inBY(int n1,int p){
	int flg=0;
	for(int i=1;i<1<<(N_MAX+1);i=i<<1){
		if((n1&i)==i){
			if(flg==0){
				flg=1;
				BY[n1]+=(long long)p;
			}
			n1-=i;
		}else if(flg==1){
			BY[n1+i]+=(long long)p;
		}
	}
	return 0;
}

int initBX(){
	for(int i=1;i<N+1;++i)inBX(i,1);
	return 0;
}
int searchD1(long long x1){
//	if(BX[1]+BY[1]>x1)return 0;
//	if(BX[1<<N_MAX]+BY[1<<N_MAX]<x1)return N+1;
	int bs=0;
	for(int i=1<<(N_MAX-1);i>0;i=i>>1){
		if(BX[bs+i]+BY[bs+i]<=x1){
			x1-=(BX[bs+i]+BY[bs+i]);
			bs+=i;
		}
	}
	return bs;
}
int searchD2(long long x1){
//	if(BX[1]-BY[1]>x1)return 0;
//	if(BX[1<<N_MAX]-BY[1<<N_MAX]<x1)return N+1;
	int bs=0;
	for(int i=(1<<(N_MAX-1));i>0;i=(i>>1)){
		if(BX[bs+i]-BY[bs+i]<=x1){
			x1-=(BX[bs+i]-BY[bs+i]);
			bs+=i;
		}
	}
	return bs;
}



int main() {
	cin>>N>>Q;

	for(int i=0;i<Q;++i)cin>>X[i]>>D[i]>>L[i];

	initBX();

	int pos=0;
	for(int i=Q-1;i>-1;--i){
		if(D[i]==1){
			pos=searchD1(X[i]);
			if(pos>0){
				inBX(1,-L[i]);
				inBY(1,L[i]);
				if(pos<N){
					inBX(pos+1,L[i]);
					inBY(pos+1,-L[i]);
				}
			}
		}else{
			pos=searchD2(X[i]);
			if(pos<N){
				inBX(pos+1,L[i]);
				inBY(pos+1,L[i]);
			}
		}
	}
	for(int i=1;i<N+1;++i){
		cout<<outBY(i)<<endl;
	}



	return 0;
}

Measured memory_bytes: 9388
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

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

    set<pair<int,int> > z;
    for(i=0; i<n; i++) {
        auto it = z.lower_bound( make_pair(a[i],-i) );
        if(it==z.begin()) {
            z.insert( make_pair(a[i],-i) );
        }
        else {
            it--;
            z.erase(it);
            z.insert(make_pair(a[i],-i));
        }
    }
    printf("%d\n", (int)z.size());

    return 0;
}



Measured memory_bytes: 5376
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    a = V * T
    b = W * T
    if abs(A - B) <= a - b:
        print('YES')
    else:
        print('NO')


main()


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#include<thread>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define show(x, y); cout << x << " " << y << endl;
using namespace std;

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

    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll dp[n][n];
    memset(dp, 0, sizeof dp);
    for(int i = 0; i < n; i++){
        dp[i][i] = a[i];
    }
    for(int len = 1; len < n; len++){
        for(int i = 0, j = i + len; j < n; i++, j++){
            dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }
    cout << dp[0][n-1];
}


Measured memory_bytes: 70528