akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int n;
LL d[200005], p2[2][200005];
char s[200005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  d[0] = 0;
  for (int i = 1; i < 200005; i++) {
    int x = i, y = 0;
    while (x > 0) {
      if (x % 2 == 1) y += 1;
      x /= 2;
    }
    d[i] = d[i % y] + 1;
  }

  scanf("%d", &n);
  int cnt = 0;
  scanf("%s", s);
  for (int i = 0; i < n / 2; i++) {
    swap(s[i], s[n - i - 1]);
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      cnt += 1;
    }
  }
  LL a = cnt - 1, b = cnt + 1;
  p2[0][0] = p2[1][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (a >= 1) {
      p2[0][i] = p2[0][i - 1] * 2 % a;
    }
    p2[1][i] = p2[1][i - 1] * 2 % b;
  }
  LL sa = 0, sb = 0;
  for (int i = 0; i < n; i++) {
    if (a >= 1) {
      sa = (sa + (s[i] - '0') * p2[0][i]) % a;
    }
    sb = (sb + (s[i] - '0') * p2[1][i]) % b;
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      ans[i] = d[(sb + p2[1][i]) % b] + 1;
    } else {
      if (a == 0) {
        ans[i] = 0;
      } else {
        ans[i] = d[(sa - p2[0][i] + a) % a] + 1;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    printf("%d\n", ans[i]);
  }
  

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let ans = if a_line == "Sunny" {
        "Cloudy"
    } else if a_line == "Cloudy" {
        "Rainy"
    } else {
        "Sunny"
    };

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let output = io::stdout();

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"Sunny", br"Cloudy
",
        ),
        (
            br"Rainy", br"Sunny
",
        ),
    ];

    #[test]
    fn test_a() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int n,k;
  cin >> n >> k;
  int a[200100];
  int num[200100];
  unsigned long long sum[200100];
  
  for(int i = 0; i < 200000; i++){
      a[i] = 0;
      num[i] = 0;
      sum[i] = 0;
  }
 
  for(int i = 0; i < n; i++){
      cin >> a[i];
  }
  
  for(int i = 0; i < n; i++){
      num[a[i]] = num[a[i]] + 1;
  }
  
  sort(num,num+n, greater<int>());
  
  sum[0] = num[0];
  
  for(int i = 0; i < k; i++){
      sum[i+1] = sum[i] + num[i+1];
  }
  
  	cout << n - sum[k-1] << endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

void solve(string a, string b) {
	vvi dp(a.size()+1, vi(b.size()+1,0));
	for (int i = 1; i < dp.size(); i++) {
		for (int j = 1; j < dp[0].size(); j++) {
			if (a[i - 1] == b[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
			}
		}
	}
	cout << dp[a.size()][b.size()] << endl;
}

int main() {
	int n;
	cin >> n;
	string a, b;
	rep(i, n) {
		cin >> a >> b;
		solve(a, b);
	}
}


Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    int n; cin >> n;
    double a[100];
    rep(i, n) cin >> a[i];
    double sum = 0.0;
    rep(i, n) {
        sum += (1/a[i]);
    }
    cout << 1/sum << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rsz resize()
#define lb lower_bound
#define ub upper_bound
#define br cout << endl

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); } 
int bit(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bit(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }

template<typename T>
void leftShift(vector<T> &v, ll k) { k %= sz(v); if(k < 0) k += sz(v); rotate(v.begin(), v.begin() + k, v.end()); }
template<typename T>
void rightShift(vector<T> &v, ll k) { leftShift(v, sz(v) - k); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

inline int nxt() {
	int x;
	cin >> x;
	return x;
}

inline int nxtll() {
	ll x;
	cin >> x;
	return x;
}

void pr() {}
void sc() {}

template <typename Head, typename... Tail>
void pr(Head H, Tail... T) { cout << H << " "; pr(T...); }

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#ifndef LOCAL
string to_string(__int128 x) {
	string s = "";
	bool neg = 0;
	if(x < 0) { s += "-"; neg = 1; }
	if(!x) s += '0';
	while(x) {
		int rem = x % 10;
		s += to_string(rem);
		x /= 10;
	}
	reverse(s.begin() + neg, s.end());
	return s;
}
#endif

const int mod = 1e9 + 7; // 998244353;

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

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

void solve() {
	int n = nxt();
	vector<int> ans(n + 1, 0);
	fr(i, 2, n) {
		int x = nxt();
		ans[x]++;
	}
	fr(i, 1, n) {
		pr(ans[i]);
		br;
	}
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	
	int x, n,p;
	cin>>x>>n;
	if(n == 0){
			cout<<x;
			return 0;
	}
	set<int> s;
	rep(i,0, n-1){
		cin>>p;
		s.insert(p);
	}
	if(s.find(x) == s.end())
	{
		cout<<x;
		return 0;
	}
	auto a = s.upper_bound( x);
	auto b = s.lower_bound(x - 1);

	if(*b == x)
		cout<<x-1;
	else if(*a > x+1)
		cout<<x+1;
	else
	{

		if(x + 1 == *a && x-1 ==*b)
		{
			int i = *b-1, j = *a+1;
			//cout<<i<<" "<<j;
			auto r = s.find(j);
			auto l = s.find(i);
			while(r != s.end() && l != s.end())
			{
				i--;j++;
				r = s.find(j);
				l = s.find(i);
				//cout<<i<<" "<<j<<"\n";
			}
			if(l == s.end())
				cout<<i;
			else
				cout<<j;
		}
		else if(x+1 != *a)
			cout<<x+1;
		else
			cout<<x-1;
	}
		
}

Measured memory_bytes: 3572
#include <stdio.h>
using namespace std;
const int N = 2e5 + 5;
char s[N], t[N];

int main()
{
    int h, w, n, x, y;
    scanf("%d%d%d%d%d%s%s", &h, &w, &n, &x, &y, &s, &t);

    bool flag = true;
    int l = y, r = y, u = x, d = x;
    for (int i = 0; i < n; i ++)
    {
        switch (s[i])
        {
        case 'U': u--; break;
        case 'D': d++; break;
        case 'R': r++; break;
        case 'L': l--; break;
        }
        if (u == 0 || d == h + 1 || l == 0 || r == w + 1)
        {
            flag = false;
            break;
        }
        switch (t[i])
        {
        case 'U': if(d != 1) d--; break;
        case 'D': if(u != h) u++; break;
        case 'R': if(l != w) l++; break;
        case 'L': if(r != 1) r--; break;
        }
    }
    if (flag) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include<string>
using namespace std; 



int main()
{
  long long int n,m,y,p;
  cin>>n>>m;
  // mC2+nC2
  // combinations
  y=n*n+m*m-n-m;
  p=y/2;
  cout<<p;
  
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>

const int mod = 1e9+7;
const int MAXN = 1e5+5;
const int N = 1e5+5;

int fac[N];
int spf[MAXN]; 

void pre(int p) {
    fac[0] = 1;
    for(int i=1; i<N; i++) {
        fac[i] = (fac[i-1] * i) % p;
    }
}


void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) if (spf[j]==j) spf[j] = i; 
        } 
    } 
} 

vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long nCr(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) return 1; 
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}

///////////////////////////////////////////////////////////////////////////////////////////////////
 
void solve(int TC) { 
    int a, b, c; cin >> a >> b >> c;
    if(a == b) {
        cout << c; return;
    }
    if(b == c) {
        cout << a; return;
    }
    if(a == c) {
        cout << b; return;
    }
}
 
signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);
 
 
    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve(i);
    }
    return 0;
 
}

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

int main(int argc, char const* argv[])
{
	int *a[2];
	int candies = -1;
	int n;

	scanf("%d", &n);
	a[0] = malloc(sizeof(int) * n);
	a[1] = malloc(sizeof(int) * n);

	for(int i = 0; i < 2; i++)
		for(int j = 0; j < n; j++)
			scanf("%d", &a[i][j]);

	for(int i = 0; i < n; i++)
	{
		int cand = 0;

		for(int j = 0; j <= i; j++)
			cand += a[0][j];
		for(int j = i; j < n; j++)
			cand += a[1][j];
		if(cand > candies)
			candies = cand;
	}

	printf("%d\n", candies);
	return 0;
}


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

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

	long double x;
	long long int val = 100;
	long double r = 0.01;
	long long int res = 0;
	cin >> x;

	while(1)
	{
		long long int temp = val*r;
		val += temp;
		res++;
		if(val >= x)
		{
			break;
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int N, K;
  std::cin >> N >> K;
  std::vector<int> p(N);
  for(int i = 0 ; i < (int)p.size(); i++){
    std::cin >> p[i];
  }
  std::sort(p.begin(), p.end());
  int resa = 0;
  for(int i = 0 ; i < K ; i++){
    resa += p[i];
  }
  std::cout << resa << std::endl;
  return 0;
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }
}

Measured memory_bytes: 3656
CON_TYPE = 26
# 問題文の入力
D = gets.to_i
C = gets.split.map(&:to_i)
S = []
D.times do |d|
    S.push(Array.new(gets.split.map(&:to_i)))
end

def calc_one_day(open_type, day)
    sat_day = 0
    # puts "open_type: #{open_type}"
    CON_TYPE.times do |type|
        if(open_type == type)
            sat_day += S[day][type]
            
            # puts "sat_day: #{sat_day}"
            # puts "#{type.to_s} held. sat+=#{S[d][type]}"
        else
            sat_day -= C[type] * (day - @lasts[type])
            # puts "sat-=#{C[type] * (d - @lasts[type])}"
        end
    end
    sat_day
end

# def calc_score(arg_array)
#     opens = []
#     D.times do |d|
#         opens.push (arg_array[d].to_i - 1)
#     end

#     # 得点計算
#     sat_list = [0]
#     sat = 0
#     @lasts = Array.new(CON_TYPE, -1)
#     D.times do |d|
#         sat += calc_one_day(opens[d], d)
#         @lasts[opens[d]] = d
#         sat_list.push sat
#     end
#     sat_list[1..-1] # 最初は0
# end

# puts calc_score([1,17,13,14,13])

# 貪欲法
opens = []
scores = [0]
@lasts = Array.new(CON_TYPE, -1)
D.times do |d|
    max_sat = -99999999999
    max_type = -1
    CON_TYPE.times do |ct|
        sat = calc_one_day(ct, d )
        if max_sat < sat
            max_sat = sat
            max_type = ct
        end
    end
    @lasts[max_type] = d
    opens.push (max_type+1)
    scores.push( scores[-1] + max_sat)
end
# puts "SAMPLE: #{calc_one_day(1,0)}\t#{calc_one_day(17,1)}"##{calc_score([1,17,13,14,13])}"
# p "LASTS: #{@lasts}"
# p "SCORES: #{scores}"
# puts "ANS:"
puts opens



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

int main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int d1 = 2; d1 <= 9; d1++) {
        for (int d10 = 2; d10 <= 9; d10++) {
            if (d10 * 10 + d1 > d) continue;
            if (d10 * d1 <= m) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <math.h> 

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (i = 0; i < n; i++)
#define FOR(i, a, b) for (i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

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

int main()
{

    std::cin.tie(0);

    int n,m,a;

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> a ;
        n = n - a;
    }

    if(n>=0) (cout << n << endl);
    if(n<0) (cout << -1 << endl); 

    return 0;

}



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

using namespace std;

void chmax( string &a, string b){
 if( a == "-"){ a = b;}// aが未更新だった場合
  //それ以外の場合はaとbの大小比較
  else if( b.size() > a.size()){ a = b;}

  else if( b.size() == a.size()){
    //aとbの桁数が一致した時、最高位から順に調べていく
    a = max( a,b); }
     }

 
 
  
int match[] = {0,2,5,5,4,5,6,3,7,6};


string dp[10100];
//dpは入力が整数で出力がstring

int main(){
int N,M; cin >> N >> M;
  vector<char> A(M);
  for(int i = 0; i < M; i++){ cin >> A[i];}
  for(int i = 0; i < 10100; i++){ dp[i] = "-";}
  //-は未記入 テーブルを記入していく
  dp[0] = ""; 
  for(int i = 0; i < 10010; i++){
    for(int j = 0; j < M; j++){
      //配るDP
   if( dp[i] != "-"){
   chmax( dp[i + match[A[j] - '0']], dp[i] + A[j]); }}}
  
  cout << dp[N] << endl; return 0;}

Measured memory_bytes: 46336
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;
	S = string(" ") + S + string(" ");
	int counter = -1;
	for (int n = 2; n < S.size(); n++) {
		if (S[n] != S[n - 1])counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
l = str(input())

l = [l]

ans = 0
for i in range(n-1):
    x = str(input())
    if x not in l and l[i][-1]==x[0]:
        l.append(x)
        continue
    else:
        ans = -10000000000
        break
if ans == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9192
n= int(input())
a= list(map(int, input().split()))
from collections import Counter
c= Counter(a).most_common()
c.sort(key=lambda x: x[0],reverse=True)
tate=0
kouho=0
sei=0
chou=0
for i in c:
    if sei==0 and i[1]>=4:
        if tate:
            sei=i[0]*tate
        else:
            sei=i[0]**2
    elif chou==0 and i[1]>=2:
        if tate:
            yoko=i[0]
            chou=yoko*tate
        else:
            tate=i[0]
print(max(chou,sei))

Measured memory_bytes: 76056
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    int n,m;
    int a[200005],s[200005];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>s[i];
    }
    sort(a,a+n);
    sort(s,s+m);
    int x=0;
    for(int i=0,j=0;i<n&&j<m;)
    {
        if(a[i]==s[j])
        {
            i++;
            j++;
            x++;
        }
        else if(a[i]>s[j])j++;
        else i++;
    }
    if(x==m)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main(){
long long b;
cin>>b;
vector<long long>a;
a.push_back(b);
int c;
long long sum=1;
for(int j=0;j<a.size();j++){
    if(a[j]>1){
        a.push_back(a[j]/2);
        sum+=pow(2,j+1);
    }
    else break;
}
cout<<sum<<endl;
}/*
100
50 50
25 25 25 25
12 12 12 12 12 12 12 12
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6--16
3 3 3 3 ----32
1 1 --64
64+32+16+8+4+2+1
*/


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

int main(){
  int n,t,a,h,p;
  cin >>n >>t >>a;
  t*=1000;
  a*=1000;
  int m=10000000000;
  for(int i=0;i<n;i++){
    cin >>h;
    if(m>abs(a-t+h*6)){
      p=i+1;
      m=abs(a-t+h*6);
    }
  }
  cout <<p <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int b[10001];
int zc(int x){
    int c=0;
    while(x%2==0){
        c++;x/=2;
    }
    return c;
}
int main(){
    int n,a=0;
    cin>>n;
    for(int j=1;j<=n;j++){
        cin>>b[j];
        a+=zc(b[j]);
	}
    cout<<a<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

string solve(ll n){
	ll val = 1;
	string ret = "";
	do{
		if(n % abs((-2) * val)){
			ret += "1";
			n -= val;
		}
		else{
			ret += "0";
		}
		val *= (-2);
	}while(n);
	reverse(ret.begin(), ret.end());
	return ret;
}

int main ()
{
ll n;
cin >> n;
cout << solve(n);

return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
#define MAX 100+5
int color[MAX],m[MAX][MAX],start[MAX],stop[MAX],a[MAX]; 
//color[i]中0--白色；1--灰色；2--黑色； 
int num;
int time1=0;
void dfs(int i){
	color[i]=1;start[i]=++time1;
	for(int j=1;j<=num;j++){
		if(m[i][j]==1&&color[j]==0){
			dfs(j);
		}
	}
	color[i]=2;stop[i]=++time1;
	return ;
}
int main(){
	memset(color,0,sizeof(color));
	memset(m,0,sizeof(m));
	cin>>num;
	for(int i=1;i<=num;i++){
		int cnt;
		cin>>a[i]>>cnt;
		for(int j=0;j<cnt;j++){
			int c;cin>>c;
			m[a[i]][c]=1;
		}
	}
	for(int i=1;i<=num;i++){
		if(color[i]==0)
		dfs(i);
	}
	for(int i=1;i<=num;i++){
		cout<<a[i]<<" "<<start[a[i]]<<" "<<stop[a[i]]<<endl;
	}
} 


Measured memory_bytes: 3144
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	ll X = 0, ans = 0;
	scanf("%lld", &X);

	ans += (X/500) * 1000;
	X -= (X/500) * 500;
	ans += (X/5) * 5;
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
  #define MAX 100000
  int parent(int i){
    return i/2;
  }
  int left(int i){
    return 2*i;
  }
  int right(int i){
    return 2*i+1;
  }
  int main(){
    int H,k,A[MAX+1];
    scanf("%d",&H);
    for(k=1;k<=H;k++){
      scanf("%d",&A[k]);
    }
    for(k=1;k<=H;k++){
      printf("node %d: key = %d, ",k,A[k]);
      if(parent(k)>=1)printf("parent key = %d, ",A[parent(k)]);
      if(left(k)<=H)printf("left key = %d, ",A[left(k)]);
      if(right(k)<=H)printf("right key = %d, ",A[right(k)]);
      printf("\n");
    }
    return 0;
  }



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

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

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

    int a[n];
    rep(i,n) cin >> a[i];
    int sum=0;

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            sum+=a[i]*a[j];
        }
    }
    cout << sum << endl;
}

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

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

const ll MOD = 1e9 + 7;

using namespace std;

int main(){
  int n;cin>>n;
  int c[60];
  rep(i,60)c[i]=0;

  ll result=0;
  rep(i,n){
    ll a;cin>>a;

    rep(j,60){
      ll mask=(1LL<<j);

//      if( (((mask & a)>>j) & 1) != (a >> j)&1 )cout<<(((mask & a)>>j) & 1)<<' '<<((a >> j)&1)<<endl;

//      if((a >> j)&1){
      if(mask & a){
        result += (mask%MOD)*((i-c[j])%MOD);
      }else{
        result += (mask%MOD)*(c[j]%MOD);
      }
      result%=MOD;
    }
    rep(j,60){
      ll mask=(1LL<<j);
      if(mask & a)c[j]++;
    }
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (register int i = (n); i < (m); ++i)
#define _rep(n,m,i) for (register int i = (n); i <= (m); ++i)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
int main() {
  int a, b;
  read(a); read(b);
  if(a <= 2 * b) printf("0");
  else printf("%d\n", a - 2 * b);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main(){
  string s, t;
  cin >> s >> t;
  vector<char>r(200, 0);
  for(int i=0; i<s.length(); i++){
    if(r[t[i]]!=0 && r[t[i]]!=s[i]){
      cout << "No";
      return 0;
    }
    else r[t[i]]=s[i];
  }
  r.resize(0);
  r.resize(200, 0);
  for(int i=0; i<t.length(); i++){
    if(r[s[i]]!=0 && r[s[i]]!=t[i]){
      cout << "No";
      return 0;
    }
    else r[s[i]]=t[i];
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int a, b;
char s[105][105];
int main() {
	scanf("%d %d", &a, &b);
	a --, b --;
	for (int i = 1; i <= 50; i ++)
		for (int j = 1; j <= 100; j ++)
			s[i][j] = '.';
	for (int i = 51; i <= 100; i ++)
		for (int j = 1; j <= 100; j ++)
			s[i][j] = '#';
	for (int i = 1; b; i += 2)
		for (int j = 1; j <= 100 && b; j += 2)
			s[i][j] = '#', b --;
	for (int i = 100; a; i -= 2)
		for (int j = 100; j >= 1 && a; j -= 2)
			s[i][j] = '.', a --;
	printf("100 100\n");
	for (int i = 1; i <= 100; i ++)
		printf("%s\n", s[i] + 1);
	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    long K = lread();
    long solve(long x, long i)
    {
        if (i == N)
            return x;
        return min(solve(x * 2, i + 1), solve(x + K, i + 1));
    }

    solve(1, 0).writeln();
}


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

int main(){
    int n,m,a,b;
    cin >> n >> m;
    set<int> s_relay,g_relay;
    for(int i = 0;i < m;i++){
        cin >> a >> b;
        if(a == 1)s_relay.insert(b);
        if(b == n)g_relay.insert(a);
    }
    for(int p : s_relay){
        if(g_relay.count(p)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 9600
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r=l+1
 if l<H and A[i]<A[l]:g=l
 else:g=i
 if r<H and A[g]<A[r]:g=r
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 65488
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    cin >> d;
    if(d == 25)
    {
        cout << "Christmas";
    }
    else if(d == 24)
    {
        cout << "Christmas Eve";
    }
    else if(d == 23)
    {
        cout << "Christmas Eve Eve";
    }
    else
    {
        cout << "Christmas Eve Eve Eve";
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=310,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int n,m,dp[N][N][N];
//dp[i][j][k]表示三种颜色最后一次出现位置分别为i,j,k的方案数
//保证i>=j>=k
int L[N][5],R[N][5];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=3;j++)
		L[i][j]=0,R[i][j]=i;
	for (int i=1;i<=m;i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		L[r][x]=max(L[r][x],l);
		R[r][x+1]=min(R[r][x+1],l-1);
	}
	dp[0][0][0]=1;
	for (int i=0;i<n;i++){
		for (int j=0;j<=n;j++)
		for (int k=0;k<=n;k++){
			int v=dp[i][j][k];
			if (!v) continue;
			dp[i+1][j][k]=inc(dp[i+1][j][k],v);
			dp[i+1][i][k]=inc(dp[i+1][i][k],v);
			dp[i+1][i][j]=inc(dp[i+1][i][j],v);
		}
		//剪去不合法状态
		for (int j=0;j<=n;j++)
		for (int k=0;k<=n;k++)
		if (j<L[i+1][2]||j>R[i+1][2]||k<L[i+1][3]||k>R[i+1][3])
			dp[i+1][j][k]=0;
	}
	int ans=0;
	for (int j=0;j<=n;j++)
	for (int k=0;k<=n;k++)
		ans=inc(ans,dp[n][j][k]);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 42;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int> > ppi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl '\n'
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORS(s) for(int i=0;i<s.length();i++)
#define input int t; cin>>t; while(t--)
#define SORT(arr) sort(arr,arr+n);
#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define mod 998244353
#define MAXN 1000010
ll mE(ll x,ll y)
{
    ll result=1;
    while(y)
    {
        if(y&1)
            result=((result%MOD)*(x%MOD))%MOD;
        x=((x%MOD)*(x%MOD))%MOD;
        y>>=1;
    }
    return result%MOD;
}
int noOfDigits(ll k)
{
    int cnt=0;
    while(k)
    {
        cnt++;
        k/=10;
    }
    return cnt;
}
void solve() {
    int n;
    cin>>n;
    vector<pair<int,int> > v;
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    int cnt=0;
    for(int i=0;i<v.size();i++)
    {
        int a=v[i].f;
        int b=v[i].s;
        if(a==b){
            cnt++;
            if(cnt==3)
            {
                cout<<"Yes\n";
                return;
            }
        }
        else
            cnt=0;
    }
    cout<<"No"<<endl;
    return;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //input{
        //cout << "Case #" << t  << ": ";
        solve();
    //}
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define rep(i,n) repl(i,0,n-1)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX

int main(){
  cin.sync_with_stdio(false);
  priority_queue<int,vector<int>,greater<int> > qmin;
  priority_queue<int> qmax;

  int n;
  cin >> n;
  ll a[3*n];
  ll b[n+1];
  ll c[n+1];
  b[0] = 0;
  c[n] = 0;
  rep(i,3*n)cin>>a[i];
  rep(i,n){
    qmax.push(a[3*n-1-i]);
    qmin.push(a[i]);
    b[0] += a[i];
    c[n] += a[3*n-1-i];
  }
  ll tmp;
  repl(i,n,2*n-1){
    qmin.push(a[i]);
    tmp = qmin.top();
    qmin.pop();
    b[i-n+1] = b[i-n]+a[i]-tmp;
  }

  for(auto i=2*n-1;i>=n;i--){
    qmax.push(a[i]);
    tmp = qmax.top();
    qmax.pop();
    c[i-n] = c[i-n+1]+a[i]-tmp;
  }
  ll t= -1e14;
  rep(i,n+1){
    if(t<=b[i]-c[i])t=b[i]-c[i];
  }
  cout << t << endl;
}

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

using namespace std;


int main()
{
  string s;
  cin >> s;

  if(s == "Sunny")
    {
      cout << "Cloudy" << endl;
    }
  else if(s == "Cloudy")
    {
      cout << "Rainy" << endl;
    }
  else
    {
      cout << "Sunny" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,k;
int a[100005];
int check(long long p){
	int i=0;
	for(int j=0;j<k;j++){
		long long b=0;
		while(b+a[i]<=p){
			b+=a[i];
			i++;
			if(i==n){
				return n;
			}
		}
	}
	return i;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long min=0;
	long long max=100000*10000;
	long long mid;
	while(max-min>1){
		mid=(min+max)/2;
		if(check(mid)>=n){
			max=mid;
		}else{
			min=mid;
		}
	}
	cout<<max<<endl;
}

Measured memory_bytes: 3484
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <climits>

using namespace std;

int N,M;
int B[100010],C[100010];

int main (int argc, char const *argv[])
{
  cin >> N >> M;
  for (size_t i = 1; i <= N; i++) C[i] = 1;
  B[1]=1;
  for (size_t i = 0; i < M; i++) {
    int x,y;
    cin >> x >> y;
    if (B[x]) B[y]=1;
    --C[x];
    if(!C[x]) B[x]=0;
    ++C[y];
  }
  int ans=0;
  for (size_t i = 1; i <= N; i++) if(B[i]) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 7)

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

dp = [-1] * (1 << n)
dp[0] = 1


def dfs(bit, i):
    if dp[bit] != -1:
        return dp[bit]
    else:
        tmp = 0
        for j in range(n):
            if bit & (1 << j) and a[i][j]:
                tmp += dfs(bit ^ (1 << j), i + 1)
    dp[bit] = tmp % mod
    return dp[bit]


print(dfs(2 ** n - 1, 0))


Measured memory_bytes: 62944
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, long long Z, long long W, std::vector<long long> a) {
  if (N > 1) {
    print(max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W)));
  } else {
    print(abs(a[N - 1] - W));
  }
}

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


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

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

int main() {
    int n; cin >> n;
    int cnt = 0, max_cnt = 0;
    int h, pre_h;
    cin >> pre_h;
    for(int i=0; i<n-1; i++){
        cin >> h;
        if(pre_h>=h){
            cnt++;
        }
        else{
            cnt = 0;
        }
        pre_h = h;
        max_cnt = max(max_cnt, cnt);
    }    
    cout << max_cnt << endl;
    return 0;
}


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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

const lli MOD = 1000000007;

int main () {
    int n, m;
    cin >> n >> m;
    vector<lli> x(n);
    vector<lli> y(m);
    REP (i, 0, n) cin >> x[i];
    REP (i, 0, m) cin >> y[i];
    lli X = 0;
    REP (i, 0, n) {
        lli t = ((i * x[i]) % MOD - ((n - i - 1) * x[i]) % MOD + MOD) % MOD;
        X = (X + t) % MOD;
    }
    lli Y = 0;
    REP (i, 0, m) {
        lli t = ((i * y[i]) % MOD - ((m - i - 1) * y[i]) % MOD + MOD) % MOD;
        Y = (Y + t) % MOD;
    }
    cout << (X * Y) % MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a%2==1&&b%2==1) {
      cout << "Yes" << '\n';
  }else {
      cout << "No" << '\n';
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
int N,M,lin[maxn],len;
struct edge{
	int y,next,v;
}e[maxn*4];
inline void insert(int xx,int yy,int vv){
	e[++len].next=lin[xx];
	lin[xx]=len;
	e[len].y=yy;
	e[len].v=vv;
}
struct my{
	int id;
	long long v;
	my(int id=0,long long v=0){
		this->id=id;
		this->v=v;
	}
	bool friend operator<(const my&A,const my&B){
		return A.v>B.v;
	}
};
priority_queue<my>pq;
long long dis[maxn];
bool vis[maxn];
void dijkstra(){
	memset(dis,10,sizeof(dis));
	pq.push(my(1,0));
	dis[1]=0;
	while(!pq.empty()){
		my t=pq.top();
		pq.pop();
		int x=t.id;
		if(vis[x])
			continue;
		vis[x]=1;
		for(int i=lin[x];i;i=e[i].next){
			if(dis[e[i].y]>dis[x]+e[i].v){
				dis[e[i].y]=dis[x]+e[i].v;
				pq.push(my(e[i].y,dis[e[i].y]));
			}
		}
	}
	if(dis[N]==dis[0])
		puts("-1");
	else
		cout<<dis[N]<<endl;
}
int main(){
	//freopen("in","r",stdin);
	N=read(),M=read();
	for(int i=N;i>1;i--)
		insert(i,i-1,0);
	for(int i=1;i<=M;i++){
		int x=read(),y=read(),v=read();
		insert(x,y,v);
	}
	dijkstra();
	return 0;
}


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

int main(){
    int n,l;
    cin >> n >> l;
    string S[n];
    for(int i=0;i<n;i++){
        cin >> S[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(S[i]>S[j]){
                swap(S[i],S[j]);
            }
        }
        
    }
    string ans;
    for(int i=0;i<n;i++){
        ans+=S[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def fib(n)
  fibList = [1,1]
  2.upto(n) do |i|
    fibList[i] = fibList[i-1] + fibList[i-2]
  end
  fibList[n]
end

if __FILE__ == $0
  n = gets.to_i
  p fib(n)
end

Measured memory_bytes: 6092
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define int long long
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int MOD = 1e9 + 7, mod = 1e9 + 7;
const int M = 1e6 + 10;
LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
LL invf[M], fac[M] = {1};
void fac_inv_init(LL n, LL p) {  //调用fac_inv_init(MOD,MOD);
    FOR(i, 1, n)
    fac[i] = i * fac[i - 1] % p;
    invf[n - 1] = bin(fac[n - 1], p - 2, p);
    FORD(i, n - 2, -1)
    invf[i] = invf[i + 1] * (i + 1) % p;
}
inline LL C(LL n, LL m) {  // n >= m >= 0
    return n < m || m < 0 ? 0 : fac[n] * invf[m] % MOD * invf[n - m] % MOD;
}
LL Lucas(LL n, LL m) {  // m >= n >= 0
    return m ? C(n % MOD, m % MOD) * Lucas(n / MOD, m / MOD) % MOD : 1;
}
struct Point {
    int x, y;
} p[5000];
bool cmp(Point a, Point b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
int h, w, n, dp[5000], x, y;
int32_t main() {
    memset(dp, 0, sizeof dp);
    fac_inv_init(M, MOD);
    cin >> h >> w >> n;
    h--, w--;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].x >> p[i].y;
        p[i].x--, p[i].y--;
    }
    sort(p + 1, p + 1 + n, cmp);
    p[++n].x = h;
    p[n].y = w;
    for (int i = 1; i <= n; i++) {
        dp[i] = C(p[i].x + p[i].y, p[i].x);
        for (int j = 1; j < i; j++) {
            int tmp = C(p[i].x + p[i].y - p[j].x - p[j].y, p[i].x - p[j].x);
            dp[i] = (dp[i] + mod - dp[j] * tmp % mod) % mod;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong(), b = scan.nextLong(), c = scan.nextLong();
		
		if(c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int main(){
    int N;
    std::cin >> N;

    std::vector<std::string> v;
    REP(i, N){
        std::string s;
        std::cin >> s;
        v.push_back(s);
    }
    
    std::string a[4];
    REP(i, 3){
        a[i] = "99999999";
    }

    REP(i, N){
        REP(j, N){
            if(i == j){continue;}

            std::string s = v[i] + v[j];
            for(int k=2;k>=0;k--){
                if(s.size() < a[k].size() || (s.size() == a[k].size() && s < a[k])){
                    a[k+1] = a[k];
                    a[k] = s;
                }
            }
        }
    }

    std::cout << a[2] << std::endl;
}

Measured memory_bytes: 1532
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  constexpr int kMax = 1e5 + 1;
  bool b[kMax] = {};
  set<int> ds;
  b[0] = true; b[1] = true;
  for (int i = 2; i < kMax; ++i) {
    if (b[i]) continue;
    ds.insert(i);
    for (int j = 1; i * j < kMax; ++j) {
      b[j*i] = true;
    }
  }

  LL s[kMax] = {};
  s[0] = 0, s[1] = 0; s[2] = 0;
  for (int i = 3; i < kMax; i += 2) {
    if (ds.count(i) && ds.count((i+1)/2)) {
      s[i] = s[i-2] + 1;
    } else {
      s[i] = s[i-2];
    }
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int l, r; cin >> l >> r;
    cout << s[r] - s[l-2] << endl;
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#include <ctime>
#define Maxn 100005
#define Maxm 1000005
#define Mod 9973
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define random(x) (rand()%x)
#define LL long long
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
char str[Maxn<<1];
int main()
{
	//input;output;
	while(~scanf("%s",str))
	{
		for(int i=0;i<4;i++)
			printf("%c",str[i]);
		printf(" ");
		for(int i=4;i<12;i++)
			printf("%c",str[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = a;
    int ans = 1;
    while(sum<b){
      ans++;
      sum+=a-1;
    }
    if(b==1)ans=0;
    System.out.print(ans);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

#define INF (1<<29)
 
using namespace std;
 
int main(void){
  
  int n,m,p,a,b,x,y,z,in;
  double dp[(1<<8)][31],graph[31][31];
  vector<int>t;
  
  while(cin >> n >> m >> p >> a >> b){
    if(!(n|m|p|a|b))break;
    
    t.clear();
    
    fill(graph[0],graph[31],-1);
    fill(dp[0],dp[(1<<8)],INF);

    for(int i=0;i<n;i++){
      cin >> in;
      t.push_back(in);
    }
    
    for(int i=0;i<p;i++){
      cin >> x >> y >> z;
      graph[x][y]=graph[y][x]=z;
    }
    
    dp[0][a]=0;
    double res=INF;
    for(int S=0;S<(1<<8);S++){
      res=min(res,dp[S][b]);
      for(int v=1;v<=m;v++){
	for(int i=0;i<n;i++){
	  if(!(S>>i & 1)){
	    for(int u=1;u<=m;u++){
	      if(graph[v][u]>=0){
		dp[S|(1<<i)][u]=min(dp[S|(1<<i)][u],dp[S][v]+graph[v][u]/t[i]);
	      }
	    }
	  }
	}
      }
    }
    if(res==INF)printf("Impossible\n");
    else printf("%.3f\n",res);
  }
  
  return 0;
}

Measured memory_bytes: 1308
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();
    let mut ans = 0;
    for i in 1..(n + 1) {
        if 1 <= i && i <= 9 || 100 <= i && i <= 999 || 10000 <= i && i <= 99999 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352