akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1505,p=1000000007;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,f[N][N];
typedef unsigned short us;
us a[N][N],l[N][N],r[N][N];
ll ans;
char ch[N];
inline void chkmin(us &x,us y){if (x>y) x=y;}
inline void chkmax(us &x,us y){if (x<y) x=y;}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		scanf(" %s",ch+1);
		for (int j=1;j<=n;j++)
		a[i][j]=(ch[j]=='#') ? 0 : (ch[j]-'0');
	}
	memset(l,0x3f,sizeof(l));
	for (int i=n;i;i--)
	for (int j=n;j;j--)
	if (a[i][j]){
		int t=f[i+1][j]+f[i][j+1];
		if (!a[i][j+1]){l[j][i]=r[j][i]=j;}
		else if (!a[i+1][j]){
			memcpy(l[j]+i,l[j+1]+i,(n-i+1)*2);
			memcpy(r[j]+i,r[j+1]+i,(n-i+1)*2);
			l[j][i]=j;
		}
		else{
			l[j][i]=j;r[j][i]=r[j+1][i];
			us las=0;
			for (int x=i+1;x<=n;x++){
				if ((l[j+1][x]<=r[j][x])&&(las<l[j+1][x])) t-=f[x][l[j+1][x]];
				chkmax(las,r[j][x]);
				chkmin(l[j][x],l[j+1][x]);chkmax(r[j][x],r[j+1][x]);
			}
		}
		ans+=a[i][j]*t;
		f[i][j]=a[i][j]+t;
	}
	else{memset(l[j]+i,0x3f,(n-i+1)*2);memset(r[j]+i,0,(n-i+1)*2);}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 22400
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


// Modint
struct Mint {
	static const long long mod = (long long)(1e9 + 7);
	long long val;

	Mint() { val = 0; }
	Mint(long long a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(long long p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0)
			std::cerr << "WARNING: inv() is called with 0." << std::endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	long long ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	long long ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, long long b) {
	return a.pow(b);
}


int main() {
	int n, k; std::cin >> n >> k;
	std::vector<Mint> d(k + 1);
	Mint ans = 0;
	for (int i = k; i >= 1; i--) {
		d[i] = pow(Mint(k / i), (long long)n);
		int w = 2*i;
		while (w <= k) {
			d[i] -= d[w];
			w += i;
		}
		ans += Mint(i)*d[i];
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
	int n, x;
	vector<int> a;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a.push_back(x);
	}

	for(int i=a.size()-1;i>=0;i--){
		if(i != a.size()-1) cout<<" ";
		cout<<a[i];
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>

typedef struct {
	int x;
	int y;
}posi_t;

int main(void) {
	int w, h;
	posi_t posi[2] = { 0 };

	scanf("%d %d %d %d", &w, &h, &posi[0].x, &posi[0].y);
	posi[1].x = w - posi[0].x;
	posi[1].y = h - posi[0].y;
	printf("%.10Lf", (long double)w * h / 2);
	if (posi[1].x == posi[0].x && posi[1].y == posi[0].y)
		printf(" 1");
	else printf(" 0");
	return 0;
}



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

using namespace std;

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

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

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

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

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,t;
int a[125252];
int mx[125252];

int main(){
  scanf("%d%d",&n,&t);
  REP(i,n)scanf("%d",a+i);
  FORR(i,0,n)mx[i] = max(mx[i+1],a[i]);
  ll bef = 0;
  ll t2 = t/2;
  REP(i,n)CHMAX(bef, t2 * (mx[i+1]-a[i]));
  int ans = 0;
  REP(i,n)if(t2*(mx[i+1]-a[i])==bef)ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		String n =scan.nextLine();
		int saizu =0;
		while(scan.hasNextInt()){
			int x = scan.nextInt();
			list.add(x);
		}
		for(int i=0;i<=list.size();i++){
			saizu = list.size();
			saizu -= 1;
			saizu -= i;
			System.out.print(list.get(saizu));
			if(saizu == 0){
				System.out.println("");
				break;
			}
			else{
				System.out.print(" ");
			}
		
		}
	}
}

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

using namespace std;


#define MAXN 201
const int mod = 998244353;

pair<int, int> p[MAXN];
int n, bio[MAXN][MAXN];

int check(int i, int j) {
  int ret = 1;
  set<int> s;
  s.insert(i);
  s.insert(j);
  pair<int, int> v = make_pair(p[j].first-p[i].first, p[j].second-p[i].second);
  for (int k = 0; k < n; ++k) {
    if (k==i || k==j) continue;
    pair<int, int> v2 = make_pair(p[k].first-p[i].first, p[k].second-p[i].second);
    if (v.first*v2.second-v.second*v2.first==0) {
      s.insert(k);
    }
  }
  for (auto si : s) {
    for (auto sj : s) {
      bio[si][sj] = 1;
      bio[sj][si] = 1;
    }
  }
  for (int i = 0; i < s.size(); ++i) {
    ret *= 2;
    ret %= mod;
  }
  ret--;
  ret -= s.size();
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int ans = 1;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  for (int i = 0; i < n; ++i) {
    ans *= 2;
    ans %= mod;
  }
  ans--;
  ans -= n;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (bio[i][j]) continue;
      ans -= check(i, j);
      if (ans<0) ans += mod;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int X, N; cin >> X >> N;
    vector<bool> bl(201,false);
    int buf;
    REP(i, N){
        cin >> buf;
        bl.at(buf-X + 100) = true;
    }

    REP(i, 101){
        if(bl.at(-i+100) == false){
            cout << X-i << endl;
            break;
        }
        if(bl.at(i+100) == false){
            cout << X+i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3464
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


#
void func() {
  LL N;
  cin >> N;
  vector<LL> H(N);
  REP(i, N) {
    cin >> H[i];
  }
  vector<LL> C(N);
  C[0] = 0;
  C[1] = abs(H[0] - H[1]);
  for (LL i = 2; i < N; i++) {
    C[i] = min(C[i-1] + abs(H[i] - H[i - 1]), C[i - 2]+ abs(H[i] - H[i - 2]));
  }
  cout << C[N - 1];

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 1792
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input().strip()
    T = input().strip()
    if T.startswith(S):
        return 'Yes'
    return 'No'


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9108
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
#define int long long
const int N = 4e5+10 , mod = 1e9+7;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , m , tot;
int a[N] , b[N] , tmp[N << 1] , dp[N] , tr[N << 1];
struct node{ int x , y; }s[N];
inline void add(int pos , int val) { if(pos <= 0) return ; while(pos <= tot * 2) (tr[pos] += val) %= mod , pos += (pos & (-pos));  }
inline int ask(int pos) { if(pos <= 0) return 0; int ans = 0; while(pos) (ans += tr[pos]) %= mod , pos -= (pos & (-pos)); return ans; }
inline bool cmp(const node &A , const node &B) { return A.x == B.x ? A.y > B.y : A.x < B.x; }

signed main()
{
	n = read(); m = read();
	for(int i = 1 ; i <= n ; ++i) a[i] = read();
	for(int i = 1 ; i <= m ; ++i) b[i] = read();
	int j = 1; tot = 0; 
	for(int i = 1 ; i <= n ; ++i)
	{
		if(j == 1 && a[i] <= b[j]) continue;
		while(j < m && a[i] >= b[j + 1]) j++;
		if(j == m) break; ++tot;
		s[tot].x = a[i] - b[j] , s[tot].y = b[j+1] - a[i];
		tmp[tot * 2 - 1] = s[tot].x; tmp[tot * 2] = s[tot].y;
	}
	sort(tmp + 1 , tmp + 1 + tot * 2);
	int ct = unique(tmp + 1 , tmp + 1 + tot * 2) - tmp - 1;
	for(int i = 1 ; i <= tot ; ++i)
	{
		s[i].x = lower_bound(tmp + 1 , tmp + 1 + ct , s[i].x) - tmp;
		s[i].y = lower_bound(tmp + 1 , tmp + 1 + ct , s[i].y) - tmp;
	}
	sort(s + 1 , s + 1 + tot , cmp);
	for(int i = 1 ; i <= tot ; ++i) if((i == 1) || (s[i].x != s[i-1].x || s[i].y != s[i-1].y))
	{
		dp[i] = (ask(s[i].y - 1) + 1) % mod;
		add(s[i].y , dp[i]);
	}
	int ans = 1;
	for(int i = 1 ; i <= tot ; ++i) (ans += dp[i]) %= mod;
	cout << ans << '\n';
	return 0;
}
// https://www.cnblogs.com/812-xiao-wen/p/11299126.html

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

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

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T add(T x, T y, T m) { return ((x % m)  + (y % m)) % m;}
template<typename T>   T mul(T x, T y, T m) { return ((x % m) * (long long)(y % m)) % m;}
template<typename T>   T sub(T x, T y, T m) { return add(x, -y + m);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}

int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

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

	ll h, a;
	cin >> h >> a;

	cout << (ll)ceil((double)h/a) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;

int main()
{
    double a,b,x;
    cin>>a>>b>>x;
    double s=x/a;
    double rad;
    if(s>=a*b/2)
    {
        double h=(a*b-s)*2/a;
        rad=atan2(h,a);
    }
    else
    {
        double w=s*2/b;
        rad=atan2(b,w);
    }
    double pi=acos(-1);
    double deg=rad/(2*pi)*360;
    printf("%.10f\n",deg);

    return 0;
}


Measured memory_bytes: 512
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn add357(lv: &Vec<i32>) -> Vec<i32> {
    return lv
        .iter()
        .flat_map(|&m| vec![m * 10 + 3, m * 10 + 5, m * 10 + 7])
        .collect();
}

fn is357(n: i32) -> bool {
    let mut m = n;
    let mut has3 = false;
    let mut has5 = false;
    let mut has7 = false;
    while m != 0 {
        match m % 10 {
            3 => has3 = true,
            5 => has5 = true,
            7 => has7 = true,
            _ => return false,
        }
        m /= 10;
    }
    return has3 && has5 && has7;
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut lav = vec![];
    let mut lv = vec![3i32, 5i32, 7i32];
    for _ in 0..8 {
        lv = add357(&lv);
        lav.append(&mut lv.clone());
    }

    let ans = lav.iter().filter(|&&i| i <= n && is357(i)).count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = $stdin.readline.chomp.to_i
as = $stdin.readline.chomp.split(' ').map(&:to_i)

ns = []
as.each_with_index do |e, i|
  ns.push([
    e,
    i + 1,
  ])
end

puts ns.sort_by(&:first).map { |e| e[1] }.join(' ')


Measured memory_bytes: 20568
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template <typename E>
struct SegmentTree{
  using H = function<E(E,E)>;
  Int n,height;
  H h;
  E ei;
  vector<E> laz;

  SegmentTree(H h,E ei):h(h),ei(ei){}

  void init(Int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    laz.assign(2*n,ei);
  }

  inline void propagate(Int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    laz[k]=ei;
  }

  inline void thrust(Int k){
    for(Int i=height;i;i--) propagate(k>>i);
  }

  void update(Int a,Int b,E x){
    thrust(a+=n);
    thrust(b+=n-1);
    for(Int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
  }

  E get_val(Int a){
    thrust(a+=n);
    return laz[a];
  }

  void set_val(Int a,E x){
    thrust(a+=n);
    laz[a]=x;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;

  vector<Int> ls(m),rs(m),cs(m);
  for(Int i=0;i<m;i++) cin>>ls[i]>>rs[i]>>cs[i];
  vector< vector<Int> > G(n);
  for(Int i=0;i<m;i++)
    G[--ls[i]].emplace_back(i);

  auto h=[&](Int x,Int y){return min(x,y);};
  const Int INF = 1e18;
  SegmentTree<Int> seg(h,INF);
  seg.init(n);

  seg.set_val(0,0);
  for(Int v=0;v<n;v++){
    Int d=seg.get_val(v);
    for(Int i:G[v])
      seg.update(ls[i],rs[i],d+cs[i]);
  }

  Int ans=seg.get_val(n-1);
  if(ans>=INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9984
H, W = list(map(int, input().split()))
S = []
for i in range(H):
	s = list(input())
	S.append(s)

judge = "Yes"
dx = [-1, 0, 0, 1]
dy = [0, -1, 1, 0]
for i in range(H):
	for j in range(W):
		if S[i][j] == "#":
			c = 0
			cc = 0
			for d in range(4):
				if 0 <= i + dx[d] and i + dx[d] <= H - 1 and 0 <= j + dy[d] and j + dy[d] <= W - 1:
					cc += 1
					if S[i + dx[d]][j + dy[d]] == ".":
						c += 1
			if c == cc:
				judge = "No"
				break
				

print(judge)

Measured memory_bytes: 3064
#include<cstdio>
int main(){
	long long int a,b;
	scanf("%lld%lld",&a,&b);
	for(int i=1;0==0;i++){
		a=a*2;
		if(b<a){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
// atcoder/tenka1-2019-beginner/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  str s;
  int _;
  while (cin >> _ >> s) {
    const int N = s.size() + 5;
    int a[N];
    int b[N];
    fill(a, a + N, 0);
    fill(b, b + N, 0);
    for (int i = 0; i < s.size(); ++i) {
      a[i + 1] = (s[i] == '.');
      b[i + 1] = (s[i] == '#');
    }
    for (int i = 0; i < s.size(); ++i) {
      a[i + 1] += a[i];
      b[i + 1] += b[i];
    }
    int mn = 1LL << 29;
    for (int i = 0; i <= s.size(); ++i) {
      setmin(mn, b[i] + a[s.size()] - a[i]);
    }
    cout << mn << endl;
  }

  return 0;
}


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

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

ll N;
ll X[200005];
ll Y[200005];

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

	cin >> N;

	for (int i = 0;i < N;i++){
		cin >> X[i];
		Y[i] = X[i];
	}

	sort(Y,Y+N);

	for (int i = 0;i < N;i++){
		if(X[i] <= Y[N/2-1]) cout << Y[N/2] << endl;
		else cout << Y[N/2-1] << endl;
	}

	return 0;

}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;

int main() {
	cin >> n >> k >> s;	
	typedef pair<int, int> ii;
	deque<ii> d, temp;
	for (auto e : s) {
		if (d.empty() or d.back().second + 'A' != e) {
			d.push_back({1, e - 'A'});	
		} else {
			d.back().first += 1;
		}
	} 
	bool color = 0;
	int add = 0;
	while (k--) {
		if (d[0].second == color) {				
			if (d[0].first == 1) d.pop_front();
			else d[0].first -= 1;	
			if (d.empty() or d.front().second != (1^color)) d.push_front({1, 1 ^ color});
			else d.front().first += 1;;
		} else {
			add += 1;
			color ^= 1;
			if (d[0].first == 1) d.pop_front();
			else d[0].first -= 1;
			if (d.empty() or d.back().second != color) d.push_back({1, color});
			else d.back().first += 1;
		}
		if (~k  and add == n) {
			k %= n;
		}
	}
	for (auto& e : d) e.second ^= color;
	for (auto& e : d) {
		while (e.first--) {
			putchar('A' + e.second);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 2308
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	P := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&P[i])
	}
	sort.Ints(P)
	ans := 0
	for i := 0; i < K; i++ {
		ans += P[i]
	}
	fmt.Println(ans)
}


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

typedef pair<int, int> P;

int main() {
  int n;
  while ( cin >> n, n ) {
    int ans = 0;
    int ma = 0;
    vector<P> dat(n);    
    for ( int i = 0; i < n; i++ ) {      
      string s;
      cin >> s;
      dat[i].first = (int)s.size()-1;
      if ( s[s.size()-1] == '+' ) dat[i].second = -1;
      else if ( s[s.size()-1] == '*' ) dat[i].second = -2;
      else dat[i].second = s[s.size()-1]-'0';
      ma = max(ma, (int)s.size()-1);      
    }

    while ( 1 ) {      
      /*for ( int i = 0; i < dat.size(); i++ ) {
	if ( i ) cout << " ";
	cout << dat[i].first << " " << dat[i].second;
      }
      cout << endl << endl;;*/
      if ( dat.size() == 1 ) break;
      bool flag = false;
      for ( int i = 0; i < dat.size()-2; i++ ) {
	if ( dat[i].second >= 0 ) continue;
	if ( dat[i].first != ma ) continue;	
	int c = dat[i].second;
	int d = dat[i].first;	
	int sum;
	int cnt = 2;	
	if ( d != dat[i+1].first-1 ) continue;
	if ( dat[i+1].second >= 0 && dat[i+2].second >= 0 && dat[i+1].first == dat[i+2].first ) {
	  flag = true;
	  //cout << 'a' << endl;	    	 
	  sum = dat[i+1].second;
	  cnt = 2;
	  for ( int j = i+2; j < dat.size(); j++ ) {
	    //cout << sum << endl;
	    if ( dat[j].second < 0 ) break;
	    if ( dat[j].first != dat[i+1].first ) break; 
	    if ( c == -1 ) {
	      sum += dat[j].second;
	    } else {
	      sum *= dat[j].second;
	    }
	    cnt++;
	  }
	}	
	if ( flag ) {
	  //cout << i << " " << sum << " " << cnt << endl;
	  int tmp = dat[i].first;
	  for ( int j = i; j < i+cnt; j++ ) dat.erase(dat.begin()+i);
	  dat.insert(dat.begin()+i, P(tmp, sum));	  
	  break;
	}
      }
      if ( !flag ) {
	ma--;
      }
		    
      if ( dat.size() == 1 ) break;
    }

    //cout << "end" << endl;
    cout << dat[0].second << endl;
  }
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back

int gcd(int a,int b)
{
	if(b==0)	return a;
	if(a==0)	return b;
	if(a>=b)	return gcd(b,a%b);
	else	return gcd(a,b%a);
}
int mpower(int a,int b,int m)
{
	if(b==0)	return 1;
	if(b==1)	return a%m;
	int res=1;
	a=a%m;
	while(b){
		if(b&1){
			res=(res*a)%m;
		}
		a=((a%m)*(a%m))%m;
		b>>=1;
	}
	return res;
}
int imod(int a,int m)
{
	if(gcd(a,m)!=1)	return 0;
	return mpower(a,m-2,m);
}


int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=0,sum=0,ss=0;
	int M=1000000007;
	for(int i=0;i<n;i++){
		sum+=a[i];
		sum%=M;
		ss+=(a[i]*a[i])%M;
		ss%=M;
	}
	ans=((sum%M)*(sum%M))%M;
	ans-=ss;
	ans%=M;
	ans+=M;
	ans%=M;
	int x=imod(2,M);
	ans=(ans*x)%M;
	cout << ans;


	return 0;
}


Measured memory_bytes: 5108
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N,M = map(int, input().split())
A = []
for a in input().split():
  heappush(A,-int(a))

for _ in range(M):
  tmp = heappop(A)
  heappush(A, -(-tmp//2))

print(-sum(A))


Measured memory_bytes: 14168
#include<cstdio>
#include<deque>
#include<algorithm>
using namespace std;
long l,n,x[200000],sum1[200001],sum2[200001],ans=0;
int main(){
    
    scanf("%ld %ld",&l,&n);
    sum1[0]=sum2[0]=0;
    for(int i=0;i<n;i++){
        scanf("%ld",&x[i]);
        sum1[i+1]=sum1[i]+2*x[i];
        sum2[i+1]=sum2[i]+2*(l-x[i]);
    }
    for(int i=1;i<=n;i++){
        if((n-i)%2){
            ans=max(ans,sum1[i+(n-i)/2]-sum1[i-1]+sum2[n]-sum2[i+(n-i)/2]-l+x[i+(n-i)/2]);
        }
        else{
            ans=max(ans,sum1[i+(n-i)/2]-sum1[i-1]+sum2[n]-sum2[i+(n-i)/2]-x[i+(n-i)/2-1]);
        }
        if(i==1){
            ans=max(ans,l-x[0]);
        }
        else if(i%2){
            ans=max(ans,sum2[i]-sum2[i/2]+sum1[i/2]-l+x[i/2]);
        }
        else{
            ans=max(ans,sum2[i]-sum2[i/2]+sum1[i/2]-x[i/2-1]);
        }
    }
    printf("%ld\n",ans);
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main(){
  ll n;
  cin>>n;
  ll a[n]={};
  ll r;
  ll counter;
  for(ll i=0; i<n; i++){
  cin>>a[i];}
  sort(a,a+n);
  reverse(a,a+n);
  counter=a[0];
  ll f=0;
  ll answer=1;
  ll q=0;
  for(ll i=1; i<n; i++){
  if(counter==a[i]){
  answer*=counter;
  counter=a[i+1];
  i++;
  f++;}
  counter=a[i];
  if(f==2){
  cout<<answer<<endl;
  break;}}
  if(f!=2)
  cout<<0<<endl;}
  


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

using namespace std;

int memo[2000];

void makeMemo(int v, int i, int n, int A[]) {

	memo[v] = 1;

	if (i == n)
		return;

	makeMemo(v, i + 1, n, A);
	makeMemo(v + A[i], i + 1, n, A);
}
int main() {

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

	int q;
	scanf("%d", &q);
	int m[q];
	for (int i = 0; i < q; ++i) {
		scanf("%d", &m[i]);
	}

	for (int i = 0; i < 2000; ++i)
		memo[i] = 0;

	makeMemo(0, 0, n, A);

	for (int i = 0; i < q; ++i) {
		if (memo[m[i]] == 1) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<stack>
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<P> VP;
typedef vector<int> VI;
typedef vector<VP> VVP;
typedef vector<VI> VVI;
class Pox
{
public:
  int cost,now;
  Pox():cost(0),now(0){}
  Pox(int now,int cost):now(now),cost(cost){}
};

class ope{
public:
  bool operator() (Pox a,Pox b)
  {
    return a.cost > b.cost;
  }
};

const int INF = (1<<28);
int N,M,K;
VVP G;
VI mincost;
//map<P,int> D;

int main()
{
  scanf("%d %d %d",&N,&M,&K);
  G.resize(N),mincost.resize(N);
  for(int i=0;i<N;i++)
      mincost[i] = INF;

  for(int i=0;i<M;i++)
    {
      int a,b,c;
      scanf("%d %d %d",&a,&b,&c);
      a--,b--;
      G[a].push_back(P(b,c));
      G[b].push_back(P(a,c));
      //D[P(a,b)] = D[P(b,a)] = c;
    }

  priority_queue<Pox,vector<Pox>,ope> Q;
  for(int i=0;i<K;i++)
    {
      int a;
      scanf("%d",&a);
      a--;
      Q.push(Pox(a,0));
      mincost[a] = 0;
    }

  while(!Q.empty())
    {
      Pox pox = Q.top(); Q.pop();
      int now = pox.now;
      int total = pox.cost;

      for(int i=0;i<G[now].size();i++)
	{     
	  P p = G[now][i];
	  int to = p.F;
	  int cost = p.S;
	  if(mincost[to] <= total + cost)
	    continue;

	  mincost[to] = total + cost;
	  Q.push(Pox(to,total+cost));
	}
    }


  double mex = 0;
  for(int i=0;i<N;i++)
    for(int j=0;j<G[i].size();j++)
	if(j != i && mincost[G[i][j].F] != INF && mincost[i] != INF/* && D[P(i,j)]*/)
	  mex = max(mex,(double)(mincost[i]+mincost[G[i][j].F]+G[i][j].S/*D[P(i,j)]*/)/2.0 );
	    

  cout << round(mex) << endl;

  return 0;
}

Measured memory_bytes: 4276
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,Q;
int dp[MAXN],b[MAXN];
int sum[MAXN],cnt[MAXN];
vector<int> ed[MAXN];
struct node {
    int l,r,cov;
}tr[MAXN * 4];
void build(int u,int l,int r) {
    tr[u].l = l;tr[u].r = r;tr[u].cov = 2 * N;
    if(l == r) return;
    int mid = (l + r) >> 1;
    build(u << 1,l,mid);
    build(u << 1 | 1,mid + 1,r);
}
void Change(int u,int l,int r,int v) {
    if(tr[u].l == l && tr[u].r == r) {
	tr[u].cov = min(tr[u].cov,v);
	return;
    }
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) Change(u << 1,l,r,v);
    else if(l > mid) Change(u << 1 | 1,l,r,v);
    else {Change(u << 1,l,mid,v);Change(u << 1 | 1,mid + 1,r,v);}
}
int Query(int u,int pos,int v) {
    if(tr[u].l == tr[u].r) {
	v = min(v,tr[u].cov);
	return v + tr[u].l - sum[tr[u].l];
    }
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(pos <= mid) return Query(u << 1,pos,min(v,tr[u].cov));
    else return Query(u << 1 | 1,pos,min(v,tr[u].cov));
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(b[i]);
	sum[i] = sum[i - 1] + b[i];
    }
    read(Q);
    int l,r;
    build(1,0,N);
    for(int i = 1 ; i <= Q ; ++i) {
	read(l);read(r);
	ed[r].pb(l);
    }
    dp[0] = 0;
    for(int i = 1 ; i <= N ; ++i) {
	dp[i] = i;
	if(b[i] == 0) dp[i] = min(dp[i - 1],dp[i]);
	else dp[i] = min(dp[i - 1] + 1,dp[i]);
	for(auto t : ed[i]) {
	    dp[i] = min(min(Query(1,t - 1,2 * N),dp[t - 1]) + (i - t + 1) - (sum[i] - sum[t - 1]),dp[i]);
	}
	for(auto t : ed[i]) {
	    int a = min(Query(1,t - 1,2 * N),dp[t - 1]);
	    Change(1,t,i,a - (t - 1) + sum[t - 1]);
	}
    }
    out(dp[N]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 22272
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

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

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

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

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

	n, m, d := nextInt(), nextInt(), nextInt()

	var ans float64
	if d == 0 {
		ans = float64(m-1) / float64(n)
	} else {
		ans = float64(m-1) * 2.0 * float64(n-d) / float64(n*n)
	}
	puts(ans)
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

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

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll n; cin >>n;
    vll a(n);
    REP(i,n) cin>>a[i];
    vll b(n);
    ll c =1;
    REP(i,n){
        b[i] = c;
        c++;
    }
    
    REP(i,n){
        if (a[i] != i+1){
            swap(a[i], a[a[i]-1]);
            break;
        }
    }  
    if (a==b) cout<<"YES";
    else cout<<"NO";
    return 0;
    
}

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

using namespace __gnu_pbds;
using namespace std;

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

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
const int Mod=1e9+7;
int main()
{
	int n;
	while(~sf("%d",&n))
	{
		ll ten=1;
		for(int i=0;i<n;i++)ten=(ten*10)%Mod;
		ll eight=1;
		for(int i=0;i<n;i++)eight=(eight*8)%Mod;
		ll nine=1;
		for(int i=0;i<n;i++)nine=(nine*9)%Mod;

		ll add=ten;
		ll sub=(2*nine-eight+Mod)%Mod;
		pf("%lld\n",(add-sub+Mod)%Mod);
	}
    return 0;
}



































Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		double max = 0.0;
		double min = -1.0;
		while (sc.hasNextLine()) {
			double height = Double.parseDouble(sc.nextLine());

			if (max < height) max = height;
			if ((min > height) || (min == -1.0)) min = height;
		}
		
		System.out.println(max - min);
	}
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n == 1) {
    cout << "1\n";
    cout << "0\n";
  } else if (n == 2) {
    cout << "2\n";
    cout << "0\n";
    cout << "11\n";
  } else {
    cout << n - 1 << '\n';
    for (int m = 2; m <= n; ++m) {
      cout << "1" + string(m - 2, '0') + "1\n";
    }
  }
}



Measured memory_bytes: 3240
private fun bits(x: Int): Int {
    var ret = 1
    repeat(x) { ret *= 2 }
    return ret - 1
}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val sList = (1..m).map { readLine()!!.split(" ").drop(1).map { it.toInt() - 1 }.toIntArray() }
    val pList = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var answer = 0
    val bits = bits(n)
    for (i in 0..bits) {
        sList.withIndex().all { s -> s.value.count { (i shr it) % 2 == 1 } % 2 == pList[s.index] }
            .let { if (it) answer++ }
    }

    println(answer)
}



Measured memory_bytes: 37996
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        double[] a = new double[n];
        double sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = 1 / scan.nextDouble();
            sum += a[i];
        }
        System.out.println(1 / sum);
    }
}

Measured memory_bytes: 23124
N, C = map(int, input().split())
x = [None] * N
v = [None] * N
for i in range(N):
    x[i], v[i] = map(int, input().split())

a0 = [None] * N
a = v[0] - x[0]
a0[0] = max(0, a)
for i in range(1, N):
    a += v[i] - (x[i] - x[i - 1])
    a0[i] = max(a, a0[i - 1])

a1 = [None] * N
a = v[N - 1] - (C - x[N - 1])
a1[0] = max(0, a)
for i in range(1, N):
    a += v[N - 1 - i] - ((C - x[N - 1 - i]) - (C - x[N - 1 - (i - 1)]))
    a1[i] = max(a, a1[i - 1])

result = max(a0[N - 1], a1[N - 1])
for i in range(N - 1):
    result = max(result, a0[i] - x[i] + a1[N - 1 - (i + 1)])
for i in range(N - 1):
    result = max(result, a1[i] - (C - x[N - 1 - i]) + a0[N - 1 - (i + 1)])
print(result)


Measured memory_bytes: 20176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define int long long

int GCD(int m,int n){
	if(n == 0) return m;
	else return GCD(n,m % n);
}

int LCM(int m,int n){
	int g = GCD(m,n);
	return m / g * n;
}

main(){
	int n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;
	int g = GCD(n,m);
	int l = LCM(n,m);
	char mem[100100];
	int j = 0;
	for(int i = 0; i < n; i += (l / m)){
		mem[j] = s[i];
		j++;
	}
	j = 0;
	for(int i = 0; i < m; i += (l / n)){
		if(t[i] != mem[j]){
			cout << -1 << endl;
			return 0;
		}
		j++;
	}
	cout << l << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

const int N = 1e3+5;
int a[N], b[N];
int dp[N*10];

void solve() {
  int h, n; scanf("%d%d", &h, &n);
  for (int i = 0; i < n; ++i)
    scanf("%d%d", a+i, b+i);
  for (int i = 1; i <= h; ++i) {
    dp[i] = dp[max(i-a[0], 0)]+b[0];
    for (int j = 1; j < n; ++j) {
      dp[i] = min(dp[i], dp[max(i-a[j], 0)]+b[j]);
    }
  }
  printf("%d", dp[h]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

using namespace std;

int main(){
  int a;
  int o,t;
  bool Bo,Bt;

  cin >> a;

  o = a % 100;
  t = (a - o) / 100;

  Bo = o < 13 && o > 0;
  Bt = t < 13 && t > 0;

  if (Bo && Bt) cout << "AMBIGUOUS" << endl;
  else if (Bo && !Bt) cout << "YYMM" << endl;
  else if (!Bo && Bt) cout << "MMYY" << endl;
  else cout << "NA" << endl;

  return 0;
}

Measured memory_bytes: 256
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair 
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli n,i,j,c=0;
	cin >> n;
	if(n%1000 == 0)
	{
		cout << "0" << endl;
	}
	else{
		cout << 1000 - (n%1000) << endl;
	}
}
int main()
{
	/*#ifndef ONLINE_JUDGE
	     freopen("input.txt", "r", stdin);
	     freopen("output.txt", "w", stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
		solve();
	return 0;
}





Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
int H,W,i,j;
while(1){
cin>>H>>W;
if( H ==0 && W == 0 )break;
	for ( int i = 0; i < H; i++ ){
	for ( int j = 0; j < W; j++ ){
		cout << "#";
	}cout<<endl;
}
	cout<<endl;
}
return 0;
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    vp r(n);
    vp b(n);
    rep(i,n)cin>>r[i].second>>r[i].first;
    rep(i,n)cin>>b[i].first>>b[i].second;
    sort(rall(r));
    sort(all(b));
    vb used(n,false);
    ll res=0;
    rep(i,n){
        ll nx=b[i].first;
        ll ny=b[i].second;
        rep(j,n){
            if(!used[j]&&r[j].first<ny&&r[j].second<nx){
                used[j]=true;
                res++;
                break;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3664
#include<iostream>

int main(){
  int a, b, c;
  int counter = 0;
  std::cin >> a >> b >> c;
  for(int i = a; i <= b; i++){
    if(c % i == 0) counter++;
  }
  std::cout << counter << std::endl;
 
  return 0;
}

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

int i=0,j=0,k,l,m;
ll mod=1000000007;

int main(){    
    int n,ans;cin>>n;
    vector<string> st(n);
    ans=n;

    for(i=0;i<n;i++){
        cin>>st[i];
    }

    sort(st.begin(),st.end());

    for(i=0;i<n-1;i++){
        if(st[i]==st[i+1]){ans--;}
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		Double d = scan.nextDouble();
		int count = 0;
		while (t-- > 0) {
			Double a = scan.nextDouble();
			Double b = scan.nextDouble();
			Double dis = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
			if (dis <= d) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 63164
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

double d[1010];

int main(){
  ll b = 0;
  rep(i,1,1010){
    b += i;
    d[i] = 1.*b/i;
  }
  ll n,k;
  cin>>n>>k;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  double sum = 0;
  rep(i,0,k){
    sum += d[v[i]];
  }
  double ans = sum;  
  rep(i,k,n){
    sum -= d[v[i-k]];
    sum += d[v[i]];
    ans = max(ans,sum);
  }
  printf("%20.20f\n", ans);
  return 0;
}

Measured memory_bytes: 2420