akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	ll x = x2 - x1;
	ll y = y2 - y1;
	cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
}



Measured memory_bytes: 256
import math

def main():
    temp = input().split()
    N = int(temp[0]); K = int(temp[1])
    need_omote = []
    for n in range(1, N+1):
        temp = float(K/n)
        count = 0
        while(1):
            if(temp <= 1):
                break;
            else:
                temp = temp/2
                count += 1
        need_omote.append(count)
    kakeru = 0
    for n in range(N):
        if(need_omote[n] > -35):
            kakeru += 1/(2**need_omote[n])
    ans = float(kakeru/N)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3864
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main()
{
	ll a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}

Measured memory_bytes: 256
# ALDS1_5_C Koch Curve
import math

def koch(i, p, q):
    if i == n:
        print(' '.join(map(str, p)))
        if q[0] == 100:
            print(' '.join(map(str, q)))
        return

    x1 = (2 * p[0] + q[0]) / 3
    y1 = (2 * p[1] + q[1]) / 3
    x2 = (p[0] + 2 * q[0]) / 3
    y2 = (p[1] + 2 * q[1]) / 3

    x3 = math.cos(math.radians(60)) * (x2 - x1) - math.sin(math.radians(60)) * (y2 - y1) + x1
    y3 = math.sin(math.radians(60)) * (x2 - x1) + math.cos(math.radians(60)) * (y2 - y1) + y1

    koch(i + 1, p, [x1, y1])
    koch(i + 1, [x1, y1], [x3, y3])
    koch(i + 1, [x3, y3], [x2, y2])
    koch(i + 1, [x2, y2], q)


n = int(input())

koch(0, [0, 0], [100, 0])







Measured memory_bytes: 5740
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
using namespace std;

long long f(int sign, const vector<long long>& a)
{
	long long cnt = 0;
	long long sum = 0;

	for(int i=0; i<a.size(); i++)
	{
		sum += a[i];
		if(sign*sum <= 0)
		{
			long long d = sign - sum;
			sum += d;
			cnt += abs(d);
		}
		
		sign *= -1;
	}

	return cnt;
}

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

	vector<long long> a(n);
	for(int i=0; i<n; i++)
		cin >> a[i];

	long long sum[2];
	sum[0] = f(1, a);
	sum[1] = f(-1, a);
	
	cout << min(sum[0], sum[1]) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <stack>
#include <sstream>
#include <list>
 
using namespace std;
 
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front
 
 
typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
 
 
const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
  
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i]>>b[i]>>c[i];
  
  ll dpa[100001],dpb[100001],dpc[100001];
  dpa[0]=0;
  dpb[0]=0;
  dpc[0]=0;
  
  rep(i,n){
    dpa[i+1]=max(dpb[i]+b[i],dpc[i]+c[i]);
    dpb[i+1]=max(dpc[i]+c[i],dpa[i]+a[i]);
    dpc[i+1]=max(dpa[i]+a[i],dpb[i]+b[i]);
  }

  cout<<max({dpa[n],dpb[n],dpc[n]})<<endl;
}
 

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>d;
inline int solve(int x){
    if(d[x]!=0) return d[x];
    else
    return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main(){
    d[0]=1;d[1]=2;
    int n;
    cin>>n;
    int ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int x, t; cin >> x >> t;
	int ans = x - t;
	cout << (ans < 0 ? 0 : ans) << "\n";

	return 0;
}

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


using namespace std;

class DisjointSet {
		vector<int> rank,p;
	public:
		DisjointSet(int n) {
			rank.resize(n,0);
			p.resize(n,0);
			for (int i=0; i<n; i++) make_set(i);
		}
		void make_set(int x) {
			p[x] = x;
			rank[x] = 0;
		}
		
		int findSet(int x) {
			if (p[x] != x) {
				p[x] = findSet(p[x]); //路径压缩 
			}
			return p[x];
		}
		
		bool same(int x,int y) {
			return findSet(x) == findSet(y);
		}
		
		void unite(int x,int y) {
			link(findSet(x),findSet(y));
		}
		
		void link(int x,int y) {
			if (rank[x] < rank[y]) {
				p[x] = y;
			} else {
				p[y] = x;
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}
};

int main() {
	int n,q;
	cin >> n >> q;
	DisjointSet disjointset(n);
	for (int i=0;i<q;i++) {
		int op,x,y;
		cin >> op >> x >> y;
		if (op == 0) {
			disjointset.unite(x,y);
		} else {
			cout << (int)disjointset.same(x,y) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3172
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int64_t; using ld = long double;
 
// -----------------------------------------------------------------------------

const int N = 2e5 + 5, MOD = 1e9 + 7;
int fac[N + 1], ifac[N + 1];

int modexp(int b, int e, int mod) {
    int a = 1;
    while (e > 0) {
        if (e & 1) a = ll(1) * a * b % mod;
        b = ll(1) * b * b % mod;
        e >>= 1;
    }
    return a;
}

int nCr(int n, int r) {
    if (n < r) return 0;
    return ll(1) * fac[n] * ifac[n - r] % MOD * ifac[r] % MOD;
}

void solve() {
    fac[0] = 1;
    for (int i = 1; i <= N; ++i) fac[i] = ll(1) * i * fac[i - 1] % MOD;
    ifac[N] = modexp(fac[N], MOD - 2, MOD);
    for (int i = N; i >= 1; --i) ifac[i - 1] = ll(1) * i * ifac[i] % MOD;

    int n, k; cin >> n >> k;
    ll ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans += ll(1) * nCr(n, i) * nCr(n - 1, i) % MOD;
        if (ans > MOD) ans %= MOD;
    }
    ans = (ans % MOD + MOD) % MOD;
    cout << ans << '\n';
}


int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
int D;
int c[27], s[400][27];
int L[27];
int last[27];
long long ANS = 0;
long long ans = 0;
int main(){
    scanf("%d",&D);
    for (int i = 1; i <= 26; i++) scanf("%d",&c[i]);
    for (int i = 1; i <= D; i++){
        for (int j = 1; j <= 26; j++) scanf("%d",&s[i][j]);
    }
    for (int i = 1; i <= D; i++){
        int b1 = -1;
        long long ok = 0;
        for (int t = 1; t <= 26; t++){
            long long MINUS = 0;
            long long sum = 0;
            for (int j = 1; j <= 26; j++){
                MINUS -= c[j]*(i-L[j]);
                sum += c[j];
            }
            for (int x = 1; x <= 26; x++){
                for (int y = 1; y <= 26; y++){
                    for (int z = 1; z <= 26; z++){
                        ans = ANS;

                        ans += s[i][t];
                        ans += (MINUS);
                        ans += c[t]*(i+1-L[t]);

                        if (i != D){
                            ans += s[i+1][x];
                            ans += (MINUS-sum);
                            ans += c[x]*(i+1-L[x]);
                        }

                        if (i < D-1){
                            ans += s[i+2][y];
                            ans += (MINUS-sum-sum);
                            ans += c[y]*(i+2-L[y]);
                        }

                        if (i < D-2){
                            ans += s[i+3][z];
                            ans += (MINUS-sum-sum-sum);
                            ans += c[z]*(i+3-L[z]);
                        }

                        if (b1 == -1 || ans > ok){
                            b1 = t;
                            ok = ans;
                        }
                    }

                }
            }
            //printf("for %d: %lld\n",t,ans);
        }
        ANS += s[i][b1];
        L[b1] = i;
        for (int j = 1; j <= 26; j++){
            ANS -= c[j]*(i-L[j]);
        }
        printf("%d\n",b1);
        //printf("score %lld\n",ANS);
    }
}


Measured memory_bytes: 3844
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int k = in.nextInt();

        TreeSet<String> set = new TreeSet<>();
        for (int i = 0; i < s.length(); i++) {
            for (int j = i + 1; j <= Math.min(i + 5, s.length()); j++) {
                set.add(s.substring(i, j));
            }
        }

        for (int i = 0; i < k - 1; i++) {
            set.pollFirst();
        }

        System.out.println(set.pollFirst());
    }
}

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

typedef long long ll;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;

  if (a >= k) {
    cout << a - k << " " << b << endl;
  } else {
    cout << 0 << " " << max(0LL, a + b - k) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    stack<char> s;
    string ans="";
    string S;
    cin>>S;
    rep(i,S.size()){
        if(S[i]=='B'){
            if(!s.empty())s.pop();
        } else {
            s.push(S[i]);
        }
    }
    while(!s.empty()){
        ans+=s.top();s.pop();
    }
    reverse(all(ans));
    fin(ans);
}


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

int main() {
    int n, odd = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 1)
            odd++;
    }
    if (odd % 2 == 0)
        cout << "YES" << endl;
    else cout << "NO" << endl;
} 

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
alpha = (60*H+M) * math.pi /360
beta = M * math.pi / 30
theta = min(abs(alpha-beta), 2*math.pi-(alpha-beta))

ans = math.sqrt(A*A+B*B-2*A*B*math.cos(theta))

print(ans)

Measured memory_bytes: 62504
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let s = scan.chars();
    let mut nums_left = vec![0u32;n+1];
    let mut nums_right = vec![0u32;n+1];
    for i in 0..n {
        let k = (s[i] as u8 - b'0') as u32;
        let mask = 1 << k;
        nums_left[i+1] = nums_left[i] | mask;
    }
    for i in (0..n).rev() {
        let k = (s[i] as u8 - b'0') as u32;
        let mask = 1 << k;
        nums_right[i] = nums_right[i+1] | mask;
    }
    let mut count = vec![false;1000];
    for i in 1..n-1 {
        let k = (s[i] as u8 - b'0') as usize;
        for p in 0..10 {
            for q in 0..10 {
                if (nums_left[i] >> p) & 1 == 1 && (nums_right[i+1] >> q) & 1 == 1 {
                    count[p as usize * 100 + k * 10 + q as usize] = true;
                }
            }
        }
    }
    let mut ret = 0;
    for i in 0..1000 {
        if count[i] {ret += 1;}
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

//------------------------------------------------------

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool suc = false;

    rep(i, 110) {
        if (i * a % b == c) {
            suc = true;
            break;
        }
    }

    YES(suc);

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
   cin >> n >> m;
   int x=0,arr[100000];
   for(int i=0;i<m;i++) {
       //int arr[10000];
       cin >> arr[i];
   }
   for(int i=0;i<m;i++) {
       x += arr[i];
   }
   if(x>n)
      cout << "-1" << endl;
   else
      cout << n-x << endl;
}


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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;

int n, m, p, dis[N], cnt[N];
bool inq[N], mk[N];
vector<pii> V[N];
vector<int> G[N];

void bfs(){
    memset(mk, 0, sizeof(mk));

    queue<int> Q;
    Q.push(n);

    int x;
    while(!Q.empty()){
        x = Q.front(); Q.pop();
        mk[x] = 1;
        for(int i=0; i<G[x].size(); i++){
            int j = G[x][i];
            if(!mk[j]){
                Q.push(j);
                mk[j] = 1;
            }
        }
    }
}

bool spfa(){
    bfs();

    if(!mk[1])  return 0;

    memset(dis, 0x3f, sizeof(dis));
    memset(inq, 0, sizeof(inq));
    memset(cnt, 0, sizeof(cnt));

    dis[1] = 0;
    inq[1] = 1;
    queue<int> Q;
    Q.push(1);

    int x;
    while(!Q.empty()){
        x = Q.front(); Q.pop();
        inq[x] = 0;
        for(int i=0; i<V[x].size(); i++){
            int j = V[x][i].first;
            if(!mk[j])  continue;
            int k = V[x][i].second;
            if(dis[j] > dis[x] + k){
                dis[j] = dis[x] + k;
                if(!inq[j]){
                    Q.push(j);
                    inq[j] = 1;

                    if(++cnt[j] > n)    return 1;
                }
            }
        }
    }
    return 0;
}

int main(){
    int x, y, z;
    scanf("%d %d %d", &n, &m, &p);
    for(int i=0; i<m; i++){
        scanf("%d %d %d", &x, &y, &z);
        z = p - z;
        V[x].pb(mp(y, z));
        G[y].pb(x);
    }
    if(spfa()){
        puts("-1");
        return 0;
    }
    printf("%d\n", max(0, -dis[n]));
    return 0;
}


Measured memory_bytes: 6144
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int f=in.nextInt()+1,n=in.nextInt();
		int sum=0,res=0;
		for(int i=0;i<n;i++) {
			sum+=Integer.parseInt(in.next());
		}
		
		res=sum/f+((sum%f>0)? 1:0);
		System.out.println(res);
	}

}



Measured memory_bytes: 26204
# coding: utf-8
# Here your code !
case = 1
while True:
    N = int(raw_input())
    if N == 0: break
    mat = [[0 for i in xrange(N)] for j in xrange(N)]
    n = 1
    for i in range(N): # upper half
        for j in reversed(xrange(i+1)):
            if i%2==0:
                mat[j][i-j] = n
                n += 1
            elif i%2==1:
                mat[i-j][j] = n
                n += 1
                 
    for i in range(N,2*N-1): # lower half
        for j in reversed(xrange(i-N+1,N)):
            if i%2==0:
                mat[j][i-j] = n
                n += 1
            elif i%2==1:
                mat[i-j][j] = n
                n += 1
    print 'Case %d:'%(case); case += 1
    for s in mat:
        print ''.join(map(str,[str(st).rjust(3) for st in s]))

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n;
vector<ll> a,b;
vector<bool> taken;
ll current_considered_edge = 50;

bool still_valid_dfs(ll curr, ll fini){
	//cout << curr << ' ' << fini << endl;
	if(curr == fini)return true;
	if(curr < fini)return false;
	for(ll i = 1; i <= 50; i++){
		if(taken[i] == true && i <= curr){
			if(still_valid_dfs(curr%i,fini))return true;
		}
	}
	return false;
}

bool still_valid(){
	for(int i = 0; i < n; i++){
		if(still_valid_dfs(a[i],b[i]) == false)return false;
	}
	return true;
}
int main(){
	cin >> n;
	a.resize(n);
	b.resize(n);
	taken.assign(55,true);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	while(current_considered_edge >= 1){
		taken[current_considered_edge] = false;
		if(!still_valid()){
			taken[current_considered_edge] = true;
		}
		current_considered_edge--;
	}
	ll ans = 0;
	for(int i = 1; i <= 50; i++){
		if(taken[i] == true){
			ans += pow(2,i);
		}
	}
	if(ans == 2251799813685246){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
	return 0;
}

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


int main(){
int a, b;
cin >> a>> b;
if (a%2==0||b%2==0) cout << "No" <<endl;
else cout <<"Yes" << endl;

}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    cout<<6-(in()+in())<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

vector<vector<pair<int, int>>> G(100005);
int ans[100005];

void dfs(int a, int p, int cp){
    int cl = 1;
    for(auto q:G[a]){
        int b = q.first;
        if(b == p) continue;
        if(cl == cp) cl++;
        ans[q.second] = cl;
        dfs(b, a, cl);
        cl++;
    }
}

int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= N-1; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(make_pair(b, i));
        G[b].push_back(make_pair(a, i));
    }
    int k = 0;
    for(int i = 1; i <= N; i++){
        k = max(k, (int)G[i].size());
    }
    cout << k << endl;
    dfs(1, 0, 0);
    for(int i = 1; i <= N-1; i++){
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 9344
n = gets.to_i
as = gets.split(" ").map(&:to_i)
cnt = 0

for i in 1..n-2
  cnt+=1 if (as[i-1]<as[i] && as[i]<as[i+1]) || (as[i-1]>as[i] && as[i]>as[i+1]) 
end
puts cnt


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
ll mul(ll x,ll y) {return (x*y)%MOD;}
const ll mn=1e5+4;
ll a[mn],t[mn];
int main() {
	ios_base::sync_with_stdio(false);
	ll n; scanf("%lld",&n);
	a[0]=0;a[n+1]=INF;
	t[0]=INF;t[n+1]=0;
	for (ll i=1;i<=n;i++) scanf("%lld",&t[i]);
	for (ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	ll ans=1;
	for (ll i=1;i<=n;i++) {
		if (t[i]!=t[i-1]||a[i]!=a[i+1]) {
			bool ok=true;
			if (t[i]!=t[i-1]&&t[i]>a[i])ok=false;
			if (a[i]!=a[i+1]&&a[i]>t[i])ok=false;
			if (!ok) ans=0;
		}
		else {
			ll up=min(t[i],a[i]);
			//printf("i:%lld up:%lld\n",i,up);
			ans=mul(ans,up);
		}
	}
	printf("%lld\n",ans);
}

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

using namespace std;

#define MAXN    (200010)
namespace mzry_sa
{
    int wx[MAXN],wy[MAXN],*x,*y,wss[MAXN],wv[MAXN];

    bool dacmp(int *r,int n,int a,int b,int l) {
        return a+l<n && b+l<n && r[a]==r[b]&&r[a+l]==r[b+l];
    }
    void da(int str[],int sa[],int rank[],int height[],int n,int m) {
        int *s = str;
        int *x=wx,*y=wy,*t,p;
        int i,j;
        for(i=0; i<m; i++)wss[i]=0;
        for(i=0; i<n; i++)wss[x[i]=s[i]]++;
        for(i=1; i<m; i++)wss[i]+=wss[i-1];
        for(i=n-1; i>=0; i--)sa[--wss[x[i]]]=i;
        for(j=1,p=1; p<n && j<n; j*=2,m=p) {
            for(i=n-j,p=0; i<n; i++)y[p++]=i;
            for(i=0; i<n; i++)if(sa[i]-j>=0)y[p++]=sa[i]-j;
            for(i=0; i<n; i++)wv[i]=x[y[i]];
            for(i=0; i<m; i++)wss[i]=0;
            for(i=0; i<n; i++)wss[wv[i]]++;
            for(i=1; i<m; i++)wss[i]+=wss[i-1];
            for(i=n-1; i>=0; i--)sa[--wss[wv[i]]]=y[i];
            for(t=x,x=y,y=t,p=1,i=1,x[sa[0]]=0; i<n; i++)
            x[sa[i]]=dacmp(y,n,sa[i-1],sa[i],j)?p-1:p++;
        }
        for(int i=0; i<n; i++) rank[sa[i]]=i;
        for(int i=0,j=0,k=0; i<n; height[rank[i++]]=k)
            if(rank[i]>0)
            for(k?k--:0,j=sa[rank[i]-1];
                i+k < n && j+k < n && str[i+k]==str[j+k];
                k++);
    }
}

#define MAXS    5196
char s[MAXS];
int sl;
int k;
int si[MAXS];
int sa[MAXS];
int myrank[MAXS];
int height[MAXS];

typedef unsigned int ui;
const ui P = 772002u;
ui nP[MAXS];
ui H[MAXS];

void myinit(void)
{
    int i;
    nP[0] = 1;
    for(i = 1;i <= sl;++i)
        nP[i] = nP[i-1] * P;
    H[0] = 0u;
    for(i = 1;i <= sl;++i)
        H[i] = H[i-1] * P + (ui)(s[i-1]);
}

int main(void)
{
    int i, j;
    scanf("%s", s); sl = strlen(s);
    myinit();
    scanf("%d", &k);
    for(i = 0;i < sl;++i)
        si[i] = s[i] - 'a' + 1;
    si[sl] = 0;
    mzry_sa::da(si, sa, myrank, height, sl+1, 27);
    set<ui> app;
    for(i = 1;i <= sl;++i)
    {
        int l = sa[i], r = sa[i];
        for(r = sa[i];r < sl;r++)
        {
            ui h = H[r+1] - H[l] * nP[r-l+1];
            if(app.end() == app.find(h))
            {
                app.insert(h);
                k--;
                if(0 == k)
                {
                    for(j = l;j <= r;j++)
                        putchar(s[j]);
                    puts("");
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 512
N = int(input())
S = input()
cumE = [0 for i in range(N+1)]

for i in range(N):
    if S[i] == "E":
        cumE[i+1] = cumE[i] + 1
    else:
        cumE[i+1] = cumE[i]

cumW = [i - cumE[i] for i in range(N)]
cumE2 = [cumE[N] - cumE[i+1] for i in range(N)]
print(min([cumW[i] + cumE2[i] for i in range(N)]))

Measured memory_bytes: 48648
#include<bits/stdc++.h>
namespace P_TEMPLATE{
	#define endl '\n'
	#define rgi register int
	typedef long long ll;
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL),setbuf(stdin,NULL);
	#endif
}}using namespace P_TEMPLATE;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=1000000007,inf=1201201201;

signed main()
{P_INIT();
	int n,cnt=0,a,b;
	fin>>n;
	for(rgi i=1;i<=n;++i) {
		fin>>a>>b;
		if(a==b) ++cnt;
		else cnt=0;
		if(cnt>=3) {puts("Yes"); return 0;}
	} puts("No");
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 3632
/*

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

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

signed main(){
	int n;
	cin>>n;
	vp in;
	rep(i,n){
		int a;
		cin>>a;
		in.pb({a,-1});
	}
	rep(i,n){
		int a;
		cin>>a;
		in.pb({a,1});
	}
	sort(all(in));
	n*=2;
	int out=1,MOD=1000000007,t=0;
	rep(i,n){
		if(in[i].second*t<0){
			(out*=abs(t))%=MOD;
		}
		t+=in[i].second;
	}
	
	cout<<out<<endl;
}














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

void priority_queue_insert(vector<int>& array, int v){
    array.push_back(v);
    push_heap(array.begin(), array.end());
}

int priority_queue_pop(vector<int>& array){
    if( array.size() == 0 ){
        throw std::range_error("empty");
    }

    pop_heap(array.begin(), array.end());
    int ret = array.back();
    array.pop_back();
    return ret;
}

int main(){
    int N, M;
    cin >> N >> M;

    vector<vector<int>> jobs(M+1, vector<int>());

    int A, B;
    for(int i = 0; i < N; i++ ){
        cin >> A >> B;
        if( A <= M ){
            jobs[A].push_back(B);
        }
    }

    vector<int> rewards;

    int total = 0;
    for(int i = 1; i <=M; i++ ){
        for(auto r : jobs[i]){
            priority_queue_insert(rewards, r);
        }

        if( !rewards.empty() ){
            total += priority_queue_pop(rewards);
        }
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main{
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        String  s = scanner.nextLine();
        String t = scanner.nextLine();

        char[] s_a = s.toCharArray();
        char[] t_a = t.toCharArray();

        int count = 0;

        for(int i = 0; i <= s_a.length -1; i++ ){
            if(!(s_a[i] == t_a[i])){
                count +=1;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 43288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b ,c ,d, e, f, g, h, i , num;
  cin >> a >> b >> c >> d>> e>> f >> g >> h >> i >> num;
  vector<vector<int>> card {
    {a, b, c},
    {d, e, f},
    {g, h, i}
  };
  
  vector<int> v;
  for (int i = 0; i < num; i++){
    int input;
    cin >> input;
    v.push_back(input);
  }
  
  for (int n = 0; n < v.size(); n++){
    for (int i = 0; i < card.size(); i++){
      for (int j = 0; j < card[i].size(); j++){
        if( v[n] == card[i][j]){   
            card[i][j] = 0;
        }
      }
    }
  }
  
  vector<int> ans{0,0,0};
  for (int i = 0; i < 3; i++){
    if(card[i] == ans){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  for(int i = 0; i < card.size(); i++){
    if(card[0][i] == 0 && card [1][i] == 0 && card[2][i] == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  if(card[0][0] == 0 && card[1][1] == 0 && card[2][2] == 0){
    cout << "Yes" << endl;
    return 0;
  } else if (card[0][2] == 0 && card[1][1] == 0 && card[2][0] == 0) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
  }
  
}

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

int main() {
	//input
	string S, T;
	cin >> S >> T;

	//calculation
	int s_size = S.size();
	int t_size = T.size();

	//output
	for (int i = 0; i < s_size; i++) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int s[10],c[10];

int main() {
  int n,m;
  while(input(n,m)) {
    REP(i,m) input(s[i],c[i]);
    int ans = -1;
    REP(i,1000) {
      auto x = to_string(i);
      if ((int)x.size() != n) continue;
      bool ng = 0;
      REP(j,m) {
        if (x[s[j]-1] - '0' != c[j]) {
          ng = 1;
        }
      }
      if (!ng) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int data[102][102];
void DFS(int x,int y,int gx,int gy,bool &Flag,int color){
  if((data[y][x]!=color)||(Flag==true))
    return;
  if((x==gx)&&(y==gy)){
    Flag=true;
    return;
  }
  data[y][x]=0;
  DFS(x,y+1,gx,gy,Flag,color);
  DFS(x,y-1,gx,gy,Flag,color);
  DFS(x+1,y,gx,gy,Flag,color);
  DFS(x-1,y,gx,gy,Flag,color);
}
int main(){
  int w,h;
  int sx,sy;
  int gx,gy;
  while(1){
    cin>>w>>h;
    if(!w&&!h)
      break;
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        data[i][j]=0;
      }
    }
    cin>>sx>>sy;
    cin>>gx>>gy;
    int n;
    cin>>n;
    int c,d,x,y;
    for(int i=0;i<n;i++){
      cin>>c>>d>>x>>y;
      if(d){
        for(int j=0;j<4;j++){
          for(int z=0;z<2;z++){
            data[j+y][z+x]=c;
          }
        }
      }else if(!d){
        for(int j=0;j<2;j++){
          for(int z=0;z<4;z++){
            data[j+y][z+x]=c;
          }
        }
      }
    }
    bool Flag=false;
    int color=data[sy][sx];
    if(color!=0)
      DFS(sx,sy,gx,gy,Flag,color);
    if (Flag){
      cout<<"OK"<<endl;
    }else if(!Flag){
      cout<<"NG"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3040
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: u128 = read();
    let mut temp = 100;
    let mut ans = 0;
    while x > temp {
        temp =  temp * 101 / 100;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <iostream>
using namespace std;
int main(void){
    int a, b[10000], count=0, d=0, i ,amari=0;
    cin >> a;
    for(i = 0; i < a; i++){
        cin >> b[i];
    }
  
    for(i = 0; i < a; i++){
        for(d=b[i],amari=0; amari==0;count++ ){
            amari = d%2;
            d = d/2;
            
            
        }
    }
    cout <<count-a;
    
}

Measured memory_bytes: 256
#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++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll n, t;
    sc(n) sc(t)
    ll T[n], ans = 0;
    for (int i = 0; i < n; i++) sc(T[i])
    int now = T[0];
    for (int i = 1; i < n; i++){
        if (now + t <=  T[i]) ans += t;
        else ans += T[i] - now;
        now = T[i];
    }
    ans += t;
    cout << ans << endl;
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;
std::vector<P> G;

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

    std::cin >> N >> K;

    int mx = N * (N - 1) / 2 - (N - 1);

    if(K > mx){
        std::cout << "-1" << std::endl;
        return 0;
    }

    for(int i=1;i<N;++i){
        G.emplace_back(i, N);
    }

    int t = mx - K;

    for(int i=1;i<N;++i){
        for(int j=i+1;j<N;++j){
            if(t > 0){
                G.emplace_back(i, j);
                t -= 1;
            }
        }
    }

    std::cout << G.size() << std::endl;

    for(auto &e : G){
        int u, v;
        std::tie(u, v) = e;

        std::cout << u << " " << v << std::endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
    unsigned int N;
    std::cin >> N;
    int f = N,a = 0;
    while(f > 10){
       a = a + (f % 10);
       f = f / 10;
    }
    a = a + (f % 10);
    if(N % a == 0){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
class Solver
  @@count = 0
  @@a

  def self.init_a(a)
    @@a = a
  end

  def self.merge(left, mid, right)
    n1 = mid - left
    n2 = right - mid
    l = @@a[left..mid]
    r = @@a[mid+1..right]
  
    (0..n1-1).each do |i|
      l[i] = @@a[left + i]
    end
  
    (0..n2-1).each do |i|
      r[i] = @@a[mid + i]
    end
  
    l[n1] = Float::INFINITY
    r[n2] = Float::INFINITY
    i = 0
    j = 0
    (left..right-1).each do |k|
      @@count += 1
      if l[i] <= r[j]
        @@a[k] = l[i]
        i = i + 1
      else 
        @@a[k] = r[j]
        j = j + 1
      end
    end
  end
  
  def self.mergeSort(left, right)
    if left+1 < right
      mid = (left + right)/2
      mergeSort(left, mid)
      mergeSort(mid, right)
      merge(left, mid, right)
    end
  end

  def self.puts_result
    puts @@a.join(' ')
    puts @@count
  end
end

n = gets.to_i
a = gets.split(' ').map(&:to_i)
Solver.init_a(a)
Solver.mergeSort(0, n)
Solver.puts_result


Measured memory_bytes: 57128
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define ll long long

const int maxn = 1e5 + 100;
ll n, val[maxn];

int main()
{
    scanf("%lld", &n);
    ll t = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &val[i]);
        //cout << val[i] << ' ' << t << endl;
        t = t ^ val[i];
    }
    //cout << t;
    if (t)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

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

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

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define forn(s, e) for(int i=s; i<e; ++i)
#define MOD 1000000007
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define pb push_back

ll power(ll x, ll y) { 
    ll res = 1;
  
    while (y > 0) {
        if (y & 1) 
            res = res * x;
        y = y >> 1;
        x = x * x;
    } 
    return res; 
} 

map<pair<int,int>, int> h;

bool isHonest(int u, int v){
    return h.find({u, v})->second;
}

bool isSet(int i, ll mask){
    return mask&(1<<i);
}

bool dfs(vi *g, int u, int* visited, ll mask){
    visited[u] = 1;
    bool f = true;
    for(auto v: g[u]){
        if(
            (isSet(u, mask) && isSet(v, mask) && !isHonest(u, v)) || 
            (isSet(u, mask) && !isSet(v, mask) && isHonest(u, v))
        ){
            //cout << u + 1<<  " " << v+1 << endl;
            f = false;
            break;
        }
        else{
            //cout << u+1 << " " << isSet(u, mask) <<" " <<   v+1 << " " << isSet(v, mask) << " " <<  isHonest(u, v) << endl;
        }
        if(!visited[v]){
            f = dfs(g, v, visited, mask);
            if(!f)
                break;
        }
            
    }
    return f;
}

bool isConsistent(ll mask, vi *g, int n){
    int *visited = new int[n]{0};

    forn(0, n){
        if(!visited[i]){
            if(!dfs(g, i, visited, mask))
                return false;
        }
    }
    return true;
}

int main(){
    IO
    int n, m, v, w;
    cin >> n;
    vi *g = new vi[n];
    forn(0, n){
        cin >> m;
        for(int j=0; j<m; ++j){
            cin >> v >> w;
            --v;
            g[i].pb(v);
            h.insert({{i, v}, w});
        }
    }

    ll lim = power(2, n);
    int _m = -1;
    forn(0, lim){
        //cout << "NUMBER : " << i << endl;
        if(isConsistent(i, g, n)){ 
            _m = max(_m, __builtin_popcount(i));
            //cout << "got it" << endl;
        }
        //cout << "------------------" << endl;
    }

    cout << _m << endl;
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    long long A[N];
    long long ans=0;
    for(long long i=0;i<N;i++){
        cin>>A[i];
        ans+=A[i]-1;
    }
    cout<<ans<<endl;
}


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

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++)
    cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (x - vec.at(i) >= 0) {
      x -= vec.at(i);
      count++;  
    }
  }
  
  if (x == vec.at(N-1))
    count += 1;
 
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#define rep(a) for(int i = 0; i < a; i++)
//
//class restaurant {
//public:
//	string city = "";
//	int point = 0;
//	int id = 0;
//	bool operator<(const restaurant &another) const
//	{
//		return city < another.city;
//	}
//};

int main()
{
	int N;
	std::cin >> N;
	std::vector< std::pair< std::pair<std::string, int>, int> > A(N);
	int temp;
	rep(N)
	{
		std::cin >> A[i].first.first >> temp;
		A[i].first.second = temp * -1;
		A[i].second = i + 1;
	}
	std::sort(A.begin(), A.end());

	rep(N) { std::cout << A[i].second << std::endl; }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long

using namespace std;
const int MN = 1e6+7;
const int MD = 1e9+7;
const ll BIG_INF = 1e18+7;
const int INF = 2147483645;

int a[MN], n;
string s[2];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int now = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == now){
            now++;
        }
    }
    if(now == 1){
        cout << -1;
        return 0;
    }
    cout << n-(now-1);
}


Measured memory_bytes: 1024