akhauriyash/Code-Regression huggingface dataset:
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
n,k = gi
l = []
rep n do
  l << gi
end
l.sort!
sum = 0
rep n do |i|
  sum += l[i][1]
  if sum >= k
    puts l[i][0]
    break
  end
end


Measured memory_bytes: 10896
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> s = new HashSet<>();
        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }
        System.out.println(s.size());
    }
}


Measured memory_bytes: 76756
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << max((long long)0 , a - 2 * b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    REP(i, N)
    {
        cin >> p[i];
    }
    sort(ALL(p));
    int res = 0;
    REP(i, K)
    {
        res += p[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a; 
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll count = 0;
	auto found = s.find("ABC");
	if (found != string::npos)
	{
		count += 1;
	}
	while (found != string::npos)
	{
		found += 1;
		found = s.find("ABC",found);
		if (found != string::npos)
		{
			count += 1;
		}
		
	}
	cout << count;
	return 0;
}


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

int main(){
  string S;
  cin>>S;
  int n=S.size();
  if(n%2==1){
    cout<<"No"<<endl;
  }else{
    bool flag=true;
    for(int i=0;i<n;i+=2){
      if(S.at(i)!='h'||S.at(i+1)!='i'){
        flag=false;
      }
    }
    if(flag){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int h = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (h <= v[i]) {
      h = v[i];
      ans++;
    }
  }
  cout << ans << endl;
}


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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define mul(a, b) (((a) % MOD * (b) % MOD) % MOD)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define insert ins
#define ers erase
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

const int msz = 1e6;
bool primes[msz + 1];

vi sieve() {
	memset(primes, true, sizeof(primes));
	
	for(ll p = 2; p * p <= msz; p++) {
		if(primes[p] == true) {
			for(ll i = p * p; i <= msz; i += p)
				primes[i] = false;
		}
	}
	
	vi retval;
	FOR(i, 2, msz) {
		if(primes[i] == true)
			retval.pb(i);
	}
	
	return retval;
}

int main() {
	
	fastio;

    rd1(ll, n);

	vi pr = sieve();
	
	FOR(i, 0, pr.size()) {
		if(pr[i] >= n) {
			cout << pr[i];
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1916
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import deque


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split()))for _ in range(M)]

    result = 0

    for i in AB:
        b = AB[:]
        start = i[0]
        goal = i[1]
        b.remove(i)
        q = deque()
        q.append(start)

        searched = {start}
        while q:
            current = q.popleft()
            if current == goal:
                break
            for j in b:
                if current == j[0] and j[1] not in searched:
                    q.append(j[1])
                    searched.add(j[1])
                elif current == j[1] and j[0] not in searched:
                    q.append(j[0])
                    searched.add(j[0])
        else:
            result += 1

    print(result)


if __name__ == "__main__":
    main()


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

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

using namespace std;

#define MAX 100007

int main(void){
  int x;
  cin >> x;
  
  int prime[MAX];
  rep(i, MAX) prime[i] = 1;
  prime[0] = 0;
  prime[1] = 0;

  for(int i = 2; i < MAX; i++){
    if(!prime[i]) continue;

    for(int j = i+1; j < MAX; j++){
      if(!prime[j]) continue;
      if(j % i == 0) prime[j] = 0;
    }

    if(x <= i && prime[i]){
      cout << i << endl;
      return 0;
    }
  };
  return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    ll zmi = 2e9, zma = -2e9, wmi = 2e9, wma = -2e9;
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        zmi = min(zmi, x + y);
        zma = max(zma, x + y);
        wmi = min(wmi, x - y);
        wma = max(wma, x - y);
    }

    cout << max(zma - zmi, wma - wmi) << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

typedef long long ll;

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

  int exps[1003] = {0};
  const ll mod = int(1e9) + 7;

  for (int i = 2; i <= n; i++) {
    int t = i, div = 2;
    while ( div*div <= i ) {
      if (t % div == 0) {
        exps[div]++;
        t /= div;
      } else {
        div++;
      }
    }
    if (t != 1) { exps[t]++; }
  }

  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= (exps[i] + 1);
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;

int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a;
	cin >> a;
	int sum = a + (a * a) + (a * a * a);
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
using namespace std;
void re(int a, int b)
{

}
int main()
{
    #ifdef DOC
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    string s; cin >> s;
    s[0] -= '0';
    s[1] -= '0';
    s[2] -= '0';
    s[3] -= '0';
    int a, b;
    a = s[0]*10 + s[1];
    b = s[2]*10 + s[3];
    if(a <= 12 && a > 0 && b <= 12 && b > 0) cout << "AMBIGUOUS";
    else if(a <= 12 && a > 0 ) cout << "MMYY";
    else if(b <= 12 && b > 0) cout << "YYMM";
    else cout << "NA";
    
    
    
}


Measured memory_bytes: 256
#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;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int h, w, k;
	cin >> h >> w >> k;
	string s[h];
	for(int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int ans = 0;
	for(int i = 0; i < (1LL << h); i++) {
		for(int j = 0; j < (1LL << w); j++) {
			int cnt = 0;
			for(int l = 0; l < h; l++) {
				for(int m = 0; m < w; m++) {
					if((i & (1LL << l)) || (j & (1LL << m))) {

					}
					else if(s[l][m] == '#') {
						cnt++;
					}
				}
			}
			if(cnt == k) {
				ans++;
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(void){

  int a1,a2,a3,a4,b1,b2,b3,b4,resa,resb;
  
  scanf("%d%d%d%d",&a1,&a2,&a3,&a4);
  scanf("%d%d%d%d",&b1,&b2,&b3,&b4);


  resa=a1+a2+a3+a4;
  resb=b1+b2+b3+b4;
  if(resa>resb)printf("%d\n",resa);
  if(resa<resb)printf("%d\n",resb);
  if(resa==resb)printf("%d\n",resa);


  return 0;
}

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

#define ll long long
int main()
{
	int r, g, b, k;
	cin >> r >> g >> b;
	cin >> k;
	int cnt = 0;
	while(r >= g){
		g *= 2;
		cnt++;
	}
	while(g >= b){
		b *= 2;
		cnt++;
	}
	if(cnt <= k){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
using namespace std;

int N, M;
string S;
long double R;


int main(){


    cin >> N;
    vector<int> A(N);
    vector<int> num(N); 

    for(int i=0;i<N-1;i++){

        cin >> A[i];
        num[i] = 0;
    }

    for(int i=0;i<N-1;i++){
        num[A[i]-1]++;
    }
    for(int i=0;i<N;i++){
        cout << num[i] << endl;
    }
}


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

struct Point{
    double x, y;
    
    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x + p.x, y + p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(x / a, y / a); }

    double norm() {return x * x + y * y; }
    double abs() {return sqrt(norm()); }
};

typedef Point Vector;

struct Segment{
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

typedef Segment Line;

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

bool intersection(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy){
    double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);

    return (ta * tb < 0 && tc * td < 0);
}

Point getCrossPoint(Segment s1, Segment s2){
    Vector base = s2.p2 - s2.p1;
    double d1 = abs(cross(base, s1.p1 - s2.p1));
    double d2 = abs(cross(base, s1.p2 - s2.p1));
    double t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1) * t;
}

int main(){
    int q; cin>>q;
    while(q--){
        double xa, ya, xb, yb; cin>>xa>>ya>>xb>>yb;
        Segment s1 = {Point(xa, ya), Point(xb, yb)};
        int n; cin>>n;
        vector<tuple<double, double, bool>> point;
        for(int i=0; i<n; i++){
            double xs, ys, xt, yt; 
            int o, l;
            cin>>xs>>ys>>xt>>yt>>o>>l;
            Segment s2 = {Point(xs, ys), Point(xt, yt)};

            if(intersection(xa, ya, xb, yb, xs, ys, xt, yt)){
                Point p1 = getCrossPoint(s1, s2);
                double px = p1.x;
                double py = p1.y;

                if((o == 1 && l == 1) || (o == 0 && l == 0)){
                    point.emplace_back(px, py, true);
                }
                else{
                    point.emplace_back(px, py, false);
                }
            }
        }

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

        int ans = 0;
        for(int i=0; i<(int)point.size()-1; i++){
            if(get<2>(point[i]) != get<2>(point[i+1])){
                ans++;
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3060
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

#define inf 1072114514
ll a[100005];
int main()
{
  ll n, k;
  ll ans = inf;
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &a[i]);
  }
  sortup(a, n);
  for (int i = k - 1; i < n; i++)
  {
    ll tmp = a[i] - a[i - k + 1];
    ans = MIN(ans, tmp);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from itertools import accumulate


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, M, K = zz()
A = zz()
B = zz()
# 累積和を見てみる
A_sum = [0]
A_sum.extend(list(accumulate(A)))
B_sum = [0]
B_sum.extend(list(accumulate(B)))

# a_idx + b_idx を最大化
# K >= A_sum[a_idx+1] + B_sum[b_idx+1]
a_idx = bisect.bisect(A_sum, K) - 1
# b_tmp = bisect.bisect(A_sum, K)
# print(A_sum)
# print(B_sum)
# print('a_idx', a_idx)
ans = a_idx
if (a_idx == 0):
    b_idx = bisect.bisect(B_sum, K) - 1
    print(b_idx)
    exit()
else:
    for b_idx in range(1, M+1):
        # print(B_sum[b_idx] + A_sum[a_idx], a_idx, b_idx)
        while (B_sum[b_idx] + A_sum[a_idx] > K):
            a_idx -= 1
            if (a_idx < 0):
                # print(a_idx, b_idx)
                print(ans)
                exit()
        ans = max(ans, a_idx+b_idx)
# print(a_idx, b_idx)

print(max(ans, 0))


Measured memory_bytes: 68572
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
int main(){
    long double a,b;
    cin>>a>>b;
    long long ans=a*b;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    vector<ll> b;
    int idx=0;
    while(idx<n and a[idx]>=a[idx+1]) idx++;

    if(idx==n){
        cout<<1000<<endl;
        return 0;
    }

    ll ans=1000;
    ll kane=1000,kabu=0;

    kabu+=kane/a[idx];
    kane%=a[idx];

    while(idx<n-1){
        while(idx<n-1 and a[idx]<=a[idx+1]) idx++;
        kane+=kabu*a[idx];
        kabu=0;
        chmax(ans,kane);

        while(idx<n-1 and a[idx]>=a[idx+1]) idx++;
        kabu+=kane/a[idx];
        kane%=a[idx];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

int main()
{
  int a[101]={};
  int x, y;
  while(cin>>x>>y)
  {
    if(!x&&!y)
    {
      int c=0;
      for(int i=3;i<101;i++)c+=(a[i]%2);
      printf("%s\n",(c==0&&a[1]%2==1&&a[2]%2==1)?"OK":"NG");
      fill_n(a,101,0);
    }
    else
    {
      a[x]++;
      a[y]++;
    }
  }
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'

using namespace std ;

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{

    lli n,cnt=0;
    cin>>n;
    vll fact;

    for(lli i=1;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            fact.pb(i);

            if(i*i !=n)
                fact.pb(n/i);
        }
    }

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


    for(auto x:fact)
    {
        lli m = (n/x) - 1;

        if(m == 0) continue;

        lli k1 = n/m , k2 = n%m;

        if(k1 == k2) cnt+=m; 

    }

    cout<<cnt<<endl;

}

Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	char[] s = sc.next().toCharArray();
      	int x = 0;
      	int maxX = 0;
      	for(int i = 0; i < n; i++){
        	if(s[i] == 'I') x++;
          	else x--;
          	maxX = Math.max(maxX, x);
        }
      	System.out.println(maxX);
    }
}

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

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

ll h[100005];
ll d[100005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    FOR (i, 1, n) {
    	cin >> h[i];
    }

    d[0] = 1e18;
    d[1] = 0;

    FOR (i, 2, n) {
    	d[i] = min(d[i - 1] + abs(h[i] - h[i - 1]), d[i - 2] + abs(h[i] - h[i - 2])); 
    }

    cout << d[n] << endl;

	
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = str(input()).split()
b = str(input()).split()
c = [a,b]
d = [a,b]
def max(x,y):
    if x > y:
        return x
    else:
        return y 
for j in range(0,2):
    for k in range(0,n):
        if j == 0 and k == 0:
            d[j][k] = int(c[j][k])
        elif j  == 0:
            d[j][k] = d[j][k-1] + int(c[j][k])
        elif k == 0:
            d[j][k] = d[j-1][k] + int(c[j][k])
        else:
            d[j][k] = max(d[j][k-1],d[j-1][k]) + int(c[j][k])
print(d[1][n-1])
 

Measured memory_bytes: 3064
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,m,i,j,k;
		cin>>n>>m;
		for(int i=0;i<m;i++){
			ll num;
			cin>>num;
			n-=num;
		}

		n=max(n,-1LL);
		cout<<n;
	}
	return 0;
}

Measured memory_bytes: 3640
import sys
n=int(input())
for i in range(10000):
  if (i*(i-1))//2==n:
    ans=i
    break
  if i==9999:
    print('No')
    sys.exit()
t=[]
print('Yes')
print(ans)
for i in range(ans):
  t.append([])
current=1
i=1
while i<=n:
  for j in range(current,ans):
    t[j].append(str(i))
    t[current-1].append(str(i))
    i+=1
  current+=1
for i in range(ans):
  print(len(t[i]))
  print(' '.join(t[i]))
  

Measured memory_bytes: 75164
N,M = map(int,input().split())
LIKE = [True] * M

for i in range(N):
  KA = list(map(int,input().split()))
  A = KA[1:]
  
  for i in range(M):
    if not (i+1) in A:
      LIKE[i] = False
      
print(LIKE.count(True))

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

ll solve() {
    ll N, a, a_max = -1e7, a_min = 1e7;
    int i_max, i_min;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        A[i] = a;
        if ( a_max < a ) {
            a_max = a;
            i_max = i;
        }
        if ( a_min > a ) {
            a_min = a;
            i_min = i;
        }
    }
    bool neg = false;
    if ( a_max < 0 ) {
        neg = true;
    } else if ( abs(a_min) > a_max ) {
        neg = true;
    }
    vector<pii> ans;
    for ( int i = 0; i < N; i++ ) {
        if ( neg ) {
            if ( A[i] > 0 ) ans.push_back(pii(i_min, i));
        } else {
            if ( A[i] < 0 ) ans.push_back(pii(i_max, i));
        }
    }
    if ( neg ) {
        for ( int i = N-1; i > 0; i-- ) {
            ans.push_back(pii(i,i-1));
        }
    } else {
        for ( int i = 0; i < N-1; i++ ) {
            ans.push_back(pii(i,i+1));
        }
    }

    cout << ans.size() << "\n";
    for ( int i = 0; i < ans.size(); i++ ) {
        cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
    }
    
    return 0;
}

int main() {
    solve();
    return 0;
}

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

int main() {
	long long w, h;
	cin >> w >> h;

	vector<long long> p(w);
	vector<long long> q(h);
	for (int i = 0; i < w; i++) scanf("%lld", &p[i]);
	for (int i = 0; i < h; i++) scanf("%lld", &q[i]);

	vector<pair<long long, int>> c;
	for (int i = 0; i < w; i++) c.emplace_back(p[i], 0);
	for (int i = 0; i < h; i++) c.emplace_back(q[i], 1);
	sort(c.begin(), c.end());

	long long ans = 0;
	int row = 0, col = 0;
	for (int i = 0; i < c.size(); i++) {
		long long a = c[i].first;
		int t = c[i].second;
		if (t == 0) {
			ans += (h - col + 1) * a;
			row++;
		} else {
			ans += (w - row + 1) * a;
			col++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6000
#include <iostream>

using namespace std;

int main() {
	long n, m;
	cin >> n >> m;

	if (2 * n <= m) {
		long mp = m - (2 * n);
		mp /= 4;
		cout << n + mp;
	}
	else {
		cout << m / 2;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double x1, y1, x2, y2, r;
    cin >> x1 >> y1 >> x2 >> y2;
    r = sqrt((x1 - x2)*(x1 - x2)+(y1 - y2)*(y1 - y2));
    cout << fixed;
    cout << setprecision(5) << r << endl;
    
}



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

int main()
{
    int i,j;
    char a[2][3];

    for(i=0;i<2;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }

    i=0,j=2;

    while(j>=0)
    {
        if(a[0][i]!=a[1][j]){
           cout<<"NO";
           return 0;
        }
        i++;
        j--;
    }

    cout<<"YES";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  size_t A, B;
  cin >> A >> B;

  if ((A + B) % 2 != 0){
    cout << "IMPOSSIBLE"<< endl;
    return 0;
  }

  cout << (A + B) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c = IL()
if a==b and b==c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    ll a,b,x;
    cin>>a>>b>>x;
    cout << b/x-(a+x-1)/x +1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=100005;
int n,m,i,j,k,head[N],adj[N],nxt[N],rhead[N],radj[N],rnxt[N],p[N],cnt,col[N],w[3],num;
bool t,v[N];
long long ans;
void dfs(int x)
{
	p[++cnt]=x;
	v[x]=true;
	for(int y=head[x];y;y=nxt[y],++num)
		if(!v[adj[y]])
		{
			col[adj[y]]=(col[x]+1)%3;
			dfs(adj[y]);
		}
		else if(col[adj[y]]!=(col[x]+1)%3)
			t=false;
	for(int y=rhead[x];y;y=rnxt[y])
		if(!v[radj[y]])
		{
			col[radj[y]]=(col[x]-1+3)%3;
			dfs(radj[y]);
		}
		else if(col[radj[y]]!=(col[x]-1+3)%3)
			t=false;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i]=k;
		nxt[i]=head[j];
		head[j]=i;
		radj[i]=j;
		rnxt[i]=rhead[k];
		rhead[k]=i;
	}
	for(i=1;i<=n;++i)
		if(!v[i])
		{
			cnt=0;
			col[i]=num=0;
			t=true;
			dfs(i);
			if(!t)
				ans+=1ll*cnt*cnt;
			else
			{
				w[0]=w[1]=w[2]=0;
				for(j=1;j<=cnt;++j)
					w[col[p[j]]]++;
				if(w[0]&&w[1]&&w[2])
					ans+=1ll*w[0]*w[1]+1ll*w[1]*w[2]+1ll*w[2]*w[0];
				else
					ans+=num;
			}
		}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
#include<tuple>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
int inf=1000000007;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};
signed main(){
    int n,k,l;cin>>n>>k>>l;
    UnionFind road(n);
    UnionFind rail(n);
    UnionFind both(n);
    vector<int> res(n,1);
    rep(i,k){
        int p,q;cin>>p>>q;
        p--;q--;
        road.unite(p,q);
    }
    vector<int> rr(l);
    vector<int> sr(l);
    rep(i,l){
        int r,s;cin>>r>>s;
        r--;s--;
        rr[i]=r;
        sr[i]=s;
        bool flag=rail.same(r,s);
        rail.unite(r,s);
        if(road.same(r,s)&&!flag){
            //both.unite(r,s);
        }
    }
    rep(i,l){
        if(road.same(rr[i],sr[i])){
            both.unite(rr[i],sr[i]);
        }
    }
    vector<int> bothroot(n,0);
    rep(i,n)bothroot[both.root(i)]++;
    /*rep(i,n){
        res[i]=bothroot[both.root(i)];
    }*/
    vector<tuple<int,int,int>> b;
    vector<pair<int,int>> tmp(n);
    rep(i,n){
        b.emplace_back(road.root(i),rail.root(i),i);
        tmp[i].first=road.root(i);
        tmp[i].second=i;
    }
    sort(tmp.begin(),tmp.end());
    sort(b.begin(),b.end());
    b.emplace_back(inf,inf,inf);
    tmp.push_back(make_pair(inf,n));
    pair<int,int> memo=make_pair(get<0>(b[0]),get<1>(b[0]));
    res.push_back(0);
    int ans=1;
    rep1(i,n){
        pair<int,int> bbuf=make_pair(get<0>(b[i]),get<1>(b[i]));
        if(memo==bbuf){
            ans++;
        }
        else{
            rep1(j,ans){
                res[get<2>(b[i-j])]=ans;
            }
            memo=bbuf;
            ans=1;
        }
    }
    rep(i,n)cout<<res[i]<<" ";
    cout<<endl;
    rep(i,n){
        //cout<<b[i].first<<" "<<b[i].second<<endl;
    }
    return 0;
}


Measured memory_bytes: 11376
/*~~~~~~ !! Roopam Mishra !!
 
    " ॐ नमः शिवाय "
    
    जो वास्तविक नहीं है उससे कभी भी मत डरो.
    
    “And don’t you dare call this code pathetic, you foul — you evil little cockroach!!”
    Even I don't understand now what I wrote, yet you are not allowed to call this pathetic..
                                                                                ~~~~~~*/
 
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000000000000
#define endll "\n"
#define pb push_back
#define forn(i,n) for(i=0;i<n;i++)
#define forab(i,a,b) for(i=a;i<=b;i++)
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() 
{
	fast_io;
	ll n,W,i,j,w,v;
	cin>>n>>W;
	vpll vec;
	forab(i,1,n)
	{
	    cin>>w>>v;
	    vec.pb({w,v});
	}
	vec.pb({-1,-1});
	sort(vec.begin(),vec.end());
	ll a[n+1][W+1];
	forn(i,n+1)
	{
	    forn(j,W+1)
	    {
	        if(i==0 || j==0)
	        {
	            a[i][j]=0;
	        }
	        else
	        if(vec[i].ff<=j)
	        {
	            a[i][j]=max(vec[i].ss+a[i-1][j-vec[i].ff],a[i-1][j]);
	        }
	        else
	        {
	            a[i][j]=a[i-1][j];
	        }
	    }
	}
	cout<<a[n][W]<<endll;
	return 0;
} 

Measured memory_bytes: 79232
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10;

char s[N], t[N];

bool solve(vector<int> moves, int h, int p);

int main() {
	int h, w, n, si, sj;
	cin >> h >> w >> n >> si >> sj;
	cin >> (s + 1) >> (t + 1);
	vector<int> s1, s2;
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'L' or s[i] == 'R') {
			s1.pb(s[i] == 'R' ? 2 : -2);
		} else {
			s2.pb(s[i] == 'D' ? 2 : -2);
		}
		if (t[i] == 'L' or t[i] == 'R') {
			s1.pb(t[i] == 'R' ? 1 : -1);
		} else {
			s2.pb(t[i] == 'D' ? 1 : -1);
		}
	}
	if (solve(s1, w, sj) and solve(s2, h, si)) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}

bool solve(vector<int> moves, int h, int p) {
	int l = 1, r = h;
	reverse(moves.begin(), moves.end());
	for (auto &i : moves) {
		if (i == 1) {
			l = max(1, l - 1);
		} else if (i == -1) {
			r = min(h, r + 1);
		} else if (i == 2) {
			--r;
		} else {
			++l;
		}
		if (l > r) {
			return false;
		}
	}
	return (l <= p and p <= r);
}

Measured memory_bytes: 3892
// 2017/09/21 Tazoe

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

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

	int R[10000][4];
	for(int y=0; y<H; y++){
		for(int x=0; x<4; x++){
			R[y][x] = 0;
		}
	}

	for(int i=0; i<N; i++){
		int x, y;
		cin >> x >> y;

		R[y][x] = 1;
	}
/*
	for(int y=0; y<H; y++){
		for(int x=0; x<4; x++){
			cout << R[y][x];
		}
		cout << endl;
	}
*/
	int DP[10000][5];
	DP[0][0] = DP[0][1] = DP[0][2] = DP[0][3] = DP[0][4] = 0;

	for(int y=1; y<H; y++){
		DP[y][0] = max(max(max(max(DP[y-1][0], DP[y-1][1]), DP[y-1][2]), DP[y-1][3]), DP[y-1][4]);

		if(R[y][0]+R[y][1]+R[y-1][0]+R[y-1][1]==0){
			DP[y][1] = max(DP[y-1][0]+1, DP[y-1][3]+1);
		}
		else{
			DP[y][1] = -1;
		}

		if(R[y][1]+R[y][2]+R[y-1][1]+R[y-1][2]==0){
			DP[y][2] = DP[y-1][0]+1;
		}
		else{
			DP[y][2] = -1;
		}

		if(R[y][2]+R[y][3]+R[y-1][2]+R[y-1][3]==0){
			DP[y][3] = max(DP[y-1][0]+1, DP[y-1][1]+1);
		}
		else{
			DP[y][3] = -1;
		}

		if(R[y][0]+R[y][1]+R[y][2]+R[y][3]+R[y-1][0]+R[y-1][1]+R[y-1][2]+R[y-1][3]==0){
			DP[y][4] = DP[y-1][0]+2;
		}
		else{
			DP[y][4] = -1;
		}
	}
/*
	for(int y=0; y<H; y++){
		for(int j=0; j<5; j++){
			cout << DP[y][j] << ' ';
		}
		cout << endl;
	}
*/
	cout << max(max(max(max(DP[H-1][0], DP[H-1][1]), DP[H-1][2]), DP[H-1][3]), DP[H-1][4]) << endl;

	return 0;
}

Measured memory_bytes: 3432
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	int X, Y;
	cin >> X >> Y;

	rep(i, X+1) {
		if (-2 * i + 4 * X - Y == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	// cout << fixed << setprecision(15);
	//cout << ans << endl;
	cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a,b,c,i,j,z,s=0;
	cin>>a>>b>>c>>n;
	for(i=0; i<=a; i++)
		for(j=0; j<=b; j++)
			for(z=0; z<=c; z++)
				if(i*500+j*100+z*50==n)
					s++;
	cout<<s<<endl;
	return 0;
}

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

  struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
  };

  typedef struct node *Node;

  Node root;

  Node treeMinimum(Node x){
    while(x->left!=NIL)
      x=x->left;
    return x;
  }

  Node treeMaximum(Node x){
    while(x->right!=NIL)
      x=x->right;
    return x;
  }

  Node treeSearch(Node u,int num){
    while(u!=NIL&&num!=u->key){
      if(num<u->key)u=u->left;
      else u=u->right;
    }
    return u;
  }

  Node treeSuccessor(Node x){
    Node y;
    if(x->right!=NIL)return treeMinimum(x->right);
    y=x->parent;
     while(y!=NIL&&x==y->right){
      x=y;
      y=y->parent;
    }
    return y;
  }

  void treeDelete(Node z){
    Node x;
    Node y;
    if(z->left==NIL||z->right==NIL)y=z;
    else y=treeSuccessor(z);

    if(y->left!=NIL){
      x=y->left;
    }else{
      x=y->right;
    }

    if(x!=NIL){
      x->parent=y->parent;
    }

    if(y->parent==NIL){
      root=x;
    }else{
      if(y==y->parent->left){
        y->parent->left=x;
      }else{
        y->parent->right=x;
      }
    }

    if(y!=z){
      z->key=y->key;
    }
    free(y);
  }

  void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;

    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
      y=x;
      if(z->key < x->key){
        x=x->left;
      }else{
        x=x->right;
      }
    }
    z->parent = y;
    if(y==NIL){
      root=z;
    }else{
      if(z->key < y->key){
        y->left=z;
      }else{
        y->right=z;
      }
    }
  }

  void inorder(Node u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
  void preorder(Node u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }


  int main(void){
    int n, i, x;
    char c[20];
    scanf("%d", &n);

    for (i=0;i<n;i++){
      scanf("%s",c);
      if (c[0]=='f'){
        scanf("%d", &x);
        Node t=treeSearch(root,x);
        if (t!=NIL) printf("yes\n");
        else printf("no\n");
      } else if ( c[0] == 'i' ){
        scanf("%d", &x);
        insert(x);
      } else if (c[0]=='p'){
        inorder(root);
        printf("\n");
        preorder(root);
        printf("\n");
      } else if (c[0]=='d'){
        scanf("%d",&x);
        treeDelete(treeSearch(root,x));
      }
    }
    return 0;
  }



Measured memory_bytes: 20448
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
#define MAX 100005
ll arr[15][15];
ll n,m,x; 
vector<ll> v;
ll recurse(int val2, vector<ll> v)
{
    if(val2==n+1){
        for(int i=1;i<=m;i++){
            if(v[i]<x) return INT_MAX; 
        }
        return 0;
    }
    ll x=recurse(val2+1,v);
    for(int j=2;j<=m+1;j++) v[j-1]+=arr[val2][j];
    ll y=arr[val2][1]+recurse(val2+1,v);
    return min(x,y);
}
int main()
{
    fast;
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++)
    {
        ll a; 
        cin>>a;
        arr[i][1]=a;
        for(int j=1;j<=m;j++) 
        	cin>>arr[i][j+1];
    }
    for(int i=0;i<=m;i++) 
    	v.push_back(0);
    ll ans=recurse(1,v);
    ll mid=ans;
    ans+=10;
    ans+=20;
    ans+=30;
    ans+=40;
    ans+=50;
    ans=mid;
    if(ans>=INT_MAX) 
    	ans=-1;
    vector<ll> ddd;
    for (int i = 0; i < 5; ++i)
    {
    	ddd.pb(1);
    }
    ll b=ans+5;
    b=b-ans;
    if(ddd[0]==1||b==5)
    cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
long long int h;
using namespace std;
int main()
{    long long int n=1,count=1;
     scanf("%lld",&h);
    while(n*2<=h)
    {  n=n*2;
        count=count*2+1;
     // printf("n=%lld count=%lld\n",n,count);
    }
    printf("%lld",count);






    return 0;
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
S = []
for i in range(h):
    s = str(input())
    S.append(s)

Ans = [[False for _ in range(w)] for _ in range(h)]

now = 1
for i in range(h):
    for j in range(w):
        if S[i][j] == '#':
            Ans[i][j] = now
            now += 1

for i in range(h):
    now = False
    for j in range(w):
        if now == False and Ans[i][j] == False:
            continue
        elif now != False and Ans[i][j] == False:
            Ans[i][j] = now
        elif Ans[i][j] != False:
            now = Ans[i][j]

for i in range(h):
    now = False
    for j in range(w-1, -1, -1):
        if now == False and Ans[i][j] == False:
            continue
        elif now != False and Ans[i][j] == False:
            Ans[i][j] = now
        elif Ans[i][j] != False:
            now = Ans[i][j]

now = False
for i in range(h):
    if now == False and Ans[i].count(False) == w:
        continue
    elif now != False and Ans[i].count(False) == w:
        Ans[i] = now
    elif Ans[i].count(False) != w:
        now = Ans[i]

now = False
for i in range(h-1, -1, -1):
    if now == False and Ans[i].count(False) == w:
        continue
    elif now != False and Ans[i].count(False) == w:
        Ans[i] = now
    elif Ans[i].count(False) != w:
        now = Ans[i]

for i in range(h):
    print(' '.join(map(str, Ans[i])))

Measured memory_bytes: 44780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll h, n;
    cin(h);
    cin(n);

    vector<ll> a(n);
    rep2(i, n) {
        ll temp;
        cin(temp);

        h -= temp;
    }

    if (h > 0) {
        print("No")
    } else {
        print("Yes")
    }

    return 0;
}

Measured memory_bytes: 1024
/********************************************************************
* @brief https://atcoder.jp/contests/abc175/tasks/abc175_d
* @date 2020/08/16
*********************************************************************/

#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   ll n;
   cin >> n;
   vector<ll> a(n);
   rep(i,n) cin>>a[i];
   ll ans=0;
   for(int i=1; i<=n-1; i++){
       if(a[i-1]>a[i]){
           ans+=a[i-1]-a[i];
           a[i]+=a[i-1]-a[i];
       }
   }
   cout << ans << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  int ans = 0;
  int num = 1;
  while(num+=2, num <= n)
  {
    int cnt = 1;
    for(int i = 3; i * i < num; i+=2)
    {
      cnt += (num % i == 0);
    }
    ans += (cnt == 4);
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3652