akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	vector<int> T(N), A(N);
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> h1(N, -1), h2(N, -1);
	int pre = 0;
	for (int i = 0; i < N; i++) {
		if (T[i] > pre) {
			h1[i] = T[i];
		}
		pre = T[i];
	}
	pre = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] > pre) {
			h2[i] = A[i];
		}
		pre = A[i];
	}
	bool ng = false;
	for (int i = 0; i < N; i++) {
		if (h1[i] != -1 && h2[i] != -1 && h1[i] != h2[i]) {
			ng = true;
			break;
		}
		if (h1[i] != -1 && A[i] < h1[i]) {
			ng = true;
			break;
		}
		if (h2[i] != -1 && T[i] < h2[i]) {
			ng = true;
			break;
		}
	}
	if (ng) {
		puts("0");
		return 0;
	}
	ll res = 1;
	for (int i = 0; i < N; i++) {
		if (h1[i] == -1 && h2[i] == -1) {
			res = (res * min(T[i], A[i])) % mod;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

		String s = sc.next();
		s = s.substring(0,4) + s.substring(5,7) + s.substring(8,10);
		int n = Integer.parseInt(s);

		if (n <= 20190430) {
			System.out.println("Heisei");
		} else {
			System.out.println("TBD");
		}
	}
}


Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

struct UnionFind{
  vector<int> p;
  vector<ll> weight;
  UnionFind(int n){
    p.resize(n, -1);
    weight.resize(n, 0);
  }

  int find(int x){
    if(p[x] == -1)return x;
    else{
      int r = find(p[x]); 
      weight[x] += weight[p[x]]; 
      return p[x] = r;
    }
  }

  ll get_weight(int x){
    find(x);
    return weight[x];
  }

  void unite(int x, int y, ll w){
    w += get_weight(x); 
    w -= get_weight(y); 

    x = find(x);
    y = find(y);
    if(x == y)return;
    p[y] = x;
    weight[y] = w;
  }

  ll diff(int x, int y){
    return get_weight(y) - get_weight(x);
  }
};

int main(){
  int n, q;
  cin >> n >> q;
  UnionFind uf(n);
  for(int i = 0; i < q; ++i){
  	int com, x, y;
  	ll z;
  	cin >> com;
  	if(com == 0){
  		cin >> x >> y >> z;
  		uf.unite(x, y, z);
  	}
  	else{
  		cin >> x >> y;
  		if(uf.find(x) == uf.find(y)){
  			cout << uf.diff(x, y) << endl;
  		}
  		else cout << "?" << endl;
  	}
  }
  
  return 0;
}



Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
#define int long long
int P,Q,A,N;

int dfs(int p,int q,int n,int t){
    if(P*q==p*Q)return 1;
    if(P*q<p*Q)return 0;
    if(N==n)return 0;

    int ret=0;

    for(int i=t;q*i<=A;i++){
        ret+=dfs(p*i+q,q*i,n+1,i);
    }

    return ret;
}

signed main(){
    while(cin>>P>>Q>>A>>N,P||Q||A||N)
        cout<<dfs(0,1,0,1)<<endl;
    return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
int INF = 10000;
int main(){
  long long N;
  cin >> N;
  string S = to_string(N);
  int M = S.size();
  vector<vector<int>> dp(M + 1, vector<int>(2, 0));
  dp[0][1] = -INF;
  for (int i = 0; i < M; i++){
    dp[i + 1][0] = dp[i][0] + (S[i] - '0');
    for (int j = 0; j < S[i] - '0'; j++){
      dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + j);
    }
    dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + 9);
  }
  cout << max(dp[M][0], dp[M][1]) << endl;
}

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

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

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


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
string s;
char t;
int main()
{
    cin>>s;
    t=s[s.length()-1];
    if (t=='2'||t=='4'||t=='5'||t=='7'||t=='9')
    {
        cout<<"hon";
    }
    else
    {
        if (t=='0'||t=='1'||t=='6'||t=='8')
        {
            cout<<"pon";
        }
        else cout<<"bon";
    }
    return 0;
}


Measured memory_bytes: 3576
N,K=map(int,input().split())
l=list(range(1,N+1))
for i in range(K):
  d=input()
  a =input().split()
  A=list(a)
  AA=[int(n) for n in A]
  l=[i for i in l if i not in AA]
  
print(len(l))

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


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

  string s;
  cin >> s;

  cout << s.substr(0, 3) << endl;

  return 0;
}


Measured memory_bytes: 3552
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, k, s;
    cin >> n >> k >> s;

    const int MAX = 1000000000;
    vector<int> ans(n);

    if (s != MAX) {
        for (int i = 0; i < k; i++) {
            ans[i] = s;
        }
        for (int i = k; i < n; i++) {
            ans[i] = MAX;
        }
    } else {
        for (int i = 0; i < k; i++) {
            ans[i] = MAX;
        }
        for (int i = k; i < n; i++) {
            ans[i] = MAX - 1;
        }
    }

    for (int i = 0; i < n - 1; i++) {
        cout << ans[i] << ' ';
    }
    cout << ans[n - 1] << endl;

    return 0;
}

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

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define mod               1000000007
#define fr                first
#define sc                second
#define vl                vector<ll>
#define pll               pair<ll,ll>
#define u_map             unordered_map<ll,ll>

#define pi                3.141592653589793
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define printV(v) for(auto itr:v) cout<<itr<<" "; cout<<endl;
#define printA(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printC cout<<"yes"<<endl;
#define printVP(v) for(auto itr:v) cout<<itr.fr<<" "<<itr.sc<<endl;
#define cinarr(a,n) for(int i=0; i<n; i++) cin>>a[i];


vl parent;
vl rank1;

ll find(ll x)
{
	if(parent[x]==-1) return x;
	else 
	{ 
		parent[x]=find(parent[x]);
		return parent[x];
	}
	
}

void union1(ll x, ll y)
{
	ll px=find(x);
	ll py=find(y);
	
	if(px==py) return;
	parent[py]=px;
	rank1[px]=rank1[px]+rank1[py];
}





void solve(){
	ll n,m; cin>>n>>m;
	
	parent= vl (n,-1);
	rank1 = vl (n,1);
	
	for(int i=0;i<m;i++)
	{
		ll u, v; cin>>u>>v; u--; v--;
		union1(u,v);
	}
	
	ll ans=0;
	for(int i=0;i<n;i++) ans=max(ans,rank1[i]);
	cout<<ans<<endl;
	
}



signed main(){
    ios;
	int testcases=1;
	//cin >> testcases;

	while(testcases--){
	    solve();
	}

	return 0;
}


Measured memory_bytes: 6388
def f(n):
    if n % 2 == 0:
        return n // 2
    elif n % 2 == 1:
        return 3 * n + 1


s = int(input())
a = [s]
done = False
while not done:
    if f(a[-1]) in a:
        print(len(a) + 1)
        done = True
        break
    else:
        a.append(f(a[-1]))
        


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

int main(){
    int n;cin >> n;
    map<string,int> a;
    string t;
    REP(i,n){
        cin >> t;
        a[t] ^= 1;
    }
    int ans = 0;
    for(auto itr = a.begin(); itr != a.end(); ++itr){
        if(itr->second > 0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12544
import java.util.Scanner;

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

        while (true) {
            int H = stdIn.nextInt();
            int W = stdIn.nextInt();

            if (H == 0 && W == 0) {
                break;
            }

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i % 2 == 0) {
                        if (j % 2 == 0)
                            System.out.print("#");
                        else
                            System.out.print(".");
                    } else {
                        if (j % 2 == 0)
                            System.out.print(".");
                        else
                            System.out.print("#");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34884
#include <bits/stdc++.h>
using namespace std;
int la, lb;
string ch1,ch2;
char a[1005], b[1005];
int maxn;
int main()
{
	getline(cin,ch1);
	for (int i = 0; i < ch1.size(); i ++)
	if (ch1[i]>='a'&& ch1[i]<='z')a[++la] = ch1[i];
	getline(cin,ch2);
	for (int i = 0; i < ch2.size(); i ++)
	if (ch2[i]>='a'&& ch2[i]<='z')b[++lb] = ch2[i];
	for (int i = 1; i <= la - lb + 1; i ++)
	{
		int cnt = 0;
		for (int j = 1; j <= lb; j ++)
		if (a[i + j - 1] == b[j])cnt ++;
		maxn = max(cnt, maxn);
	}
	cout << lb - maxn;
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int dp[1123456] = {};
int dp2[1123456] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i,1123456) {
        dp[i] = INF;
        dp2[i] = INF;
    }
    dp[0] = 0;
    dp2[0] = 0;
    VL tetra;
    VL oddtetra;
    int cnt = 1;
    while(1){
        LL tmp = cnt * (cnt+1) * (cnt+2) / 6;
        if(tmp <= 1e6){
            tetra.eb(tmp);
            if(tmp % 2 == 1) oddtetra.eb(tmp);
            cnt++;
        }
        else{
            break;
        }
    }
    //dump(cnt)
    //cout << printVector(tetra) << endl;

    for(int p : tetra){
        FOR(i,p,1000456){
            dp[i] = min(dp[i-p]+1, dp[i]);
        }
    }
    for(int p : oddtetra){
        FOR(i,p,1000456){
            dp2[i] = min(dp2[i-p]+1, dp2[i]);
        }
    }

    //REP(i,50){
    //    cout << i << ":" << dp2[i] << endl;
    //}
    while(1){
        int x; cin >> x;
        if(x == 0) break;

        cout << dp[x] << " " << dp2[x] << endl;
    }


}



Measured memory_bytes: 11860
#include <iostream>
using namespace std;
int n, f;
int dfs(int a) {
    int ret = 0;
    while (a > 0) {
        ret += a % 10;
        a /= 10;
    }
    return ret;
}
int main(void){
    // Your code here!
    cin >> n;
    f = dfs(n);
    if (n % f == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
g = gcd(n, m)
sg, tg = n//g, m//g
for i in range(g):
  if s[sg*i] != t[tg*i]:
    print(-1)
    break
else:
  print(sg*m)

Measured memory_bytes: 5344
def main():
    n=int(input())
    A=list(map(int,input().split()))
    x=A[0]^A[1]
    for i in A:
        x^=i
    s=A[0]+A[1]
    dp=[[[-1]*2 for _ in range(2)] for _ in range(43)]
    dp[0][0][0]=0
    v=1
    a=A[0]
    for i in range(42):
        cx,ca,cs=x&1,a&1,s&1
        for j in range(2):
            for k in range(2):
                if dp[i][j][k]==-1:
                    continue
                for na in range(2):
                    for nb in range(2):
                        if na^nb!=cx:
                            continue
                        ni,nj,nk,ns=i+1,0,k,na+nb+j
                        if ns%2!=cs:
                            continue
                        if ns>=2:
                            nj=1
                        if ca<na:
                            nk=1
                        elif ca==na:
                            nk=k
                        else:
                            nk=0
                        dp[ni][nj][nk]=max(dp[ni][nj][nk],dp[i][j][k]|(v*na))
        x>>=1
        s>>=1
        a>>=1
        v<<=1
    a=dp[42][0][0]
    if a==0 or a==-1:
        ans=-1
    else:
        ans=A[0]-a
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9040
from sys import stdin
N, D = [int(i) for i in stdin.readline().split()]
point_list = []
for n in range(N):
    point_list.append([int(i) for i in stdin.readline().split()])

output = 0
for p in point_list:
    dist = (abs(p[0]) ** 2 + abs(p[1]) ** 2) ** (1/2)
    if dist <= D:
        output += 1
print(output)

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

#define Online 1
// #define multitest 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

vector<ll> Dp(200005);
int n;
// vector<vector<int>> C(200005);
vector<int> Dist;

ll Dp_com()
{
	int n = Dist.size() - 1;
	vector<int> Cumm(200005);
	Dp[n] = 1;
	// db(Dist[n]);
	Cumm[Dist[n]] = 1;
	for (int i = n - 1; i >= 0; --i)
	{
		// db(Dist[i]);
		Dp[i] = Dp[i + 1] + Cumm[Dist[i]];
		Dp[i] %= mod;
		// db(i,Dp[i]);
		Cumm[Dist[i]] += Dp[i+1];
		Cumm[Dist[i]] %= mod;
	}
	return Dp[0];
}

void solve()
{
	cin >> n;
	int k, prev = -1;
	for (int i = 0; i < n; ++i)
	{
		cin >> k;
		if (k == prev)
			continue;
		// if(fisrt==-1) first = k;
		Dist.pb(k);
		// C[k].pb(Dist.size() - 1);
		prev = k;
	}
	cout << Dp_com() << '\n';
	// for(auto it : Dp)
	// 	db(it.f,it.s);
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int cnt[1000010];
int num[1000010];
bool is_prime_small[1000010];

void segment_sieve(int a, int b) {
  for (int i = 0; i*i < b; i++) is_prime_small[i] = true;
  for (int i = 0; i < b-a; i++) num[i] = a+i;
  for (int i = 2; i*i < b; i++) {
    if (is_prime_small[i]) {
      for (int j = 2*i; j*j < b; j += i) is_prime_small[j] = false;
      for (int j = max(2LL,(a+i-1)/i)*i; j < b; j += i) {
        int tmp = j;
        while (tmp % i == 0) {
          cnt[j-a]++;
          num[j-a] /= i;
          tmp /= i;
        }
      }
    }
  }
}

int is_prime[31] = {0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int l,r;
  cin >> l >> r;
  segment_sieve(l,r+1);
  int ans = 0;
  for (int i = l; i <= r; i++) {
    ans += is_prime[cnt[i-l]+(num[i-l]!=1)];
  }
  cout << ans << endl;

  return 0;
}


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

#define EPS DBL_EPSILON
#define POW(x) ((x)*(x))

int main(){
    int n;
    double sx, sy, gx, gy;
    double x[1010], y[1010], r[1010];

    double graph[1010][1010];

    cin >> sx >> sy >> gx >> gy;

    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i] >> r[i];
    }

    x[n] = sx;
    y[n] = sy;
    r[n] = 0;

    x[n+1] = gx;
    y[n+1] = gy;
    r[n+1] = 0;

    n += 2;

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            graph[i][j] = max(sqrt(POW(x[i]-x[j]) + POW(y[i]-y[j])) - r[i] - r[j], 0.0);
        }
    }

    double dist[1010];
    for(int i = 0;i < n;i++){
        dist[i] = DBL_MAX;
    }

    dist[n-2] = 0;

    priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > > que;
    que.push(make_pair(0, n-2));

    while(!que.empty()){
        int idx = que.top().second;
        double cost = que.top().first;
        que.pop();

        for(int i = 0;i < n;i++){
            if(i != idx){
                double ncost = cost + graph[idx][i];
                if(dist[i] > ncost){
                    dist[i] = ncost;
                    que.push(make_pair(ncost, i));
                }
            }
        }
    }

    printf("%.12lf\n", dist[n-1]);
    return 0;
}

Measured memory_bytes: 13808
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
int main() {
	int a, b;
	char s;
	while (1) {
		scanf("%d %c %d", &a, &s, &b);
		if (s == '+')printf("%d\n", a + b);
		if (s == '-')printf("%d\n", a - b);
		if (s == '*')printf("%d\n", a * b);
		if (s == '/')printf("%d\n", a / b);
		if (s == '%')printf("%d\n", a % b);
		if (s == '?')break;
	}
	return 0;
}

Measured memory_bytes: 600
MAX = 3000
leap = {}.tap{|h| (4...MAX).step(4).each{|n| h[n] = true if n % 100 > 0 || n % 400 == 0}}
while gets
  a, b = $_.split.map(&:to_i)
  break if a == 0 && b == 0
  puts if $<.lineno > 1

  ret = (a..b).select{|n| leap[n]}
  puts (ret.empty? ? "NA" : ret)
end

Measured memory_bytes: 6168
import bisect

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
c.sort()

ans = 0
c_len = len(c)

for i in b:
    a_index = bisect.bisect_left(a , i)
    c_index = bisect.bisect_right(c , i)
    tmp = a_index * (c_len - c_index)
    ans += tmp
    
print(ans)




Measured memory_bytes: 23360
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

const int STRING_LEN = 10;
const int ALPHABET = 26;

using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	
	
	vector<vector<int>> prices(m,vector<int>(1));
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		if (a < m) {
			prices[a].emplace_back(b);
		}
	}

	
	int sum = 0;

	for (int i = 0; i < m; i++) {
		for (int price : prices[i]) {
			pq.push(price);
		}

		if (!pq.empty()) {
			sum += pq.top();
			pq.pop();

		}
		
	}
	
	

	cout << sum << endl;

	


}

Measured memory_bytes: 6976
#include<iostream>

using namespace std;

int main()
{
  int a[5];
  int answer=0;
  for(int i = 0 ; i < 5 ; i++){
    cin>>a[i];
    if(a[i]==0){
      answer=i+1;
    }
  }
  cout<<answer<<endl;
  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <set>
#include <tuple>

using namespace std;
typedef vector<int>VI;
typedef long long LL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define SCAN_INT(n) scanf("%i",&n)
#define SCAN_P_INT(n,m) scanf("%i %i",&n,&m)
#define PRINT_P_INT(n,m) printf("%i %i\n",n,m);
#define PRINT_INT(n) printf("%i\n",n)

#define PB push_back
#define ST first
#define ND second
#define INF 1000000000


set<int> liczby;
int n;
int suma =0;
int main(){
    SCAN_INT(n);

    while(n--){
        int temp;
        SCAN_INT(temp);
        if(liczby.count(temp)==0){
            liczby.insert(temp);
            suma++;
        }
        else{
            liczby.erase(temp);
            suma--;
        }
    }

    PRINT_INT(suma);
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  int n;
  cin >> n;
  vector<ll> a;
  ll tmp;
  rep(i,n){
    cin>>tmp;
    a.push_back(tmp);
  }
  //sort(a.begin(),a.end());
  ll sum=0;
  rep(i,n-1){
    sum += a[i]/2;
    a[i]-=2*(a[i]/2);
    if(a[i+1]>=1){
      sum+=a[i];
      a[i+1]-=a[i];
      a[i]=0;
    }
    /*rep(j,n){
      cout<<a[j]<<" ";
    }
    cout << "sum" << sum;
    cout<< endl;*/
  }
  sum+=a[n-1]/2;
  cout<<sum;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>

bool prime[1000001], dp[1000001];

int main(){
	for(int i=0;i<=1000000;i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = 0;
	for(int i=2;i*i<=1000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i)prime[j] = false;
		}
	}

	int n, x, a[30];
	while(std::cin >> n >> x, n){
		for(int i=0;i<=x;i++){
			dp[i] = false;
		}

		for(int i=0;i<n;i++){
			std::cin >> a[i];
		}

		int res = 0;

		dp[0] = true;
		for(int i=1;i<=x;i++){
			for(int j=0;j<n;j++){
				if(i-a[j] >= 0 && dp[i-a[j]]){
					dp[i] = true;
					break;
				}
			}
			if(dp[i] && prime[i]){
				res = i;
			}
		}

		if(res != 0){
			std::cout << res << std::endl;
		}else{
			std::cout << "NA" << std::endl;
		}
	}
}

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

int main(){
int N;
  cin>>N;
  vector<int>L(N);
  for(int i=0; i<N; i++){
   cin>>L[i];
  }
  
  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());
  
  int sum=0;
  for(int i=1; i<N; i++){
   sum=sum+L[i];
  }
  
  if(L[0]<sum){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",if a<6{0}else if a<13{b/2}else{b})
}


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

#define max(a,b) (((a) < (b)) ? (b) : (a))
#define min(a,b) (((a) > (b)) ? (b) : (a))
int main(void) {
    int64_t A,B;
    int64_t tmpa,tmpb;
    int64_t mina,maxa;
    int64_t i;
    cin >> A >> B;

    tmpa = A * 12.5;
    tmpb = B * 10;
    mina = min(tmpa,tmpb);
    maxa = max(tmpa+1,tmpb+1);

    for(i=mina;i<=maxa;i++) {
        if((((i* 8)/100) == A) 
            && (((i* 10)/100) == B)) {
            cout << i << endl;
            return 0;
        } 
    }

    cout << "-1\n";
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<long long> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	sort(a.begin(), a.end(), greater<long long>());
	
	int i = 0;
	long long max1 = 0;
	long long max2 = 0;
	while(i < n)
	{
		int cnt = 0;
		while(a[i] == a[i + cnt] && (i + cnt) < n)
		{
			cnt++;
			if(cnt == 2)
			{
				max1 = max2;
				max2 = a[i];
				break;
			}
		}
		if(max1 != 0)
		{
			break;
		}
		
		i += cnt;
	}
	
	if(max1 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << max1 * max2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    a78(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a78(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    fun toInt(num: String, radix: Int): Int = java.lang.Integer.parseInt(num, radix)
    val (first, second) = args[0].split(" ").map { toInt(it, 16) }
    println(when {
        first == second -> "="
        first > second -> ">"
        else -> "<"
    })
}


Measured memory_bytes: 38212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dcs
{
    class Program
    {

        class stuff
        {
            public Int32 w { get; set; }
            public Int32 v { get; set; }
        }

        static void Main(string[] args)
        {
            var NW = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();

            var tab = new Int64[NW[0] + 1, NW[1] + 1];

//           var data = new List<(Int32 w, Int32 v)>();

            var data = new List<stuff>();

            for (Int32 i = 0; i < NW[0]; ++i) {
                var wv = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
                //                data.Add((w: wv[0], v: wv[1]));

                var t = new stuff();
                t.w = wv[0];
                t.v = wv[1];
                data.Add(t);

            }

            /*
            for (Int32 i = 0; i < NW[0]; ++i)
                Console.WriteLine( data[i] );
            */

            //i番目の荷物を詰めてみる
            for (Int32 i = 1; i < NW[0] + 1; ++i)
            {

                //[1, W]の重さの範囲を試す
                for (Int32 wi = 1; wi < NW[1] + 1; ++wi)
                {
                    var t = tab[i - 1, wi];
//                    (var w, var v) = data[i - 1];
                    var w = data[i - 1].w;
                    var v = data[i - 1].v;
                    if (wi >= w)
                        t = Math.Max(tab[i - 1, wi - w] + v, t);

                    tab[i, wi] = t;
                }

            }

            /*
            for (Int32 i = 0; i < NW[0]+1; ++i)
            {
                for (Int32 j = 0; j < NW[1]+1; ++j)
                {
                    Console.Write(i+"*"+j+":"+tab[i,j]+"\t");
                }
                Console.WriteLine();
            }
            */

            Console.WriteLine(tab[NW[0],NW[1]]);
        }
    }
}


Measured memory_bytes: 90976
#include <stdio.h>
int main(){
	int p,q,r;
	if(scanf("%d%d%d",&p,&q,&r)==-1){
		return 1;
	};
	if(p>=q&&p>=r){
		printf("%d",q+r);
		}
	else if(q>=p&&q>=r){
		printf("%d",p+r);
	}
	else{
		printf("%d",p+q);
	}
	return 0;
}

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

int main() {
  int N,x;
  cin>>N>>x;
  vector<long> a(N);
  //vector<long> b(N);
  for(int j=0;j<N;j++){
    cin>>a[j];
  }
  long c=0;
  for(int i=0;i<N-1;i++){
    long sum = a[i+1]+a[i];
    if(sum>x){
      if(a[i+1]>=sum-x){
        c += sum-x;
        a[i+1] -= sum-x;
      }
      else if(a[i+1]<sum-x){
        c += a[i+1];
        c += sum-x-a[i+1];
        a[i+1] -= a[i+1];
        a[i] -= sum-x-a[i+1];
      }

    }
    //cout<<a[i]<<endl;
  }

cout<<c<<endl;

  }


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
long long ct(long long);
int N, Q, S, T;
int main() {
	cin >> N >> Q >> S >> T;
	long long *line;
	line = new long long[N + 1];
	int bh,nh;
	cin >> bh;
	line[0] = 0;
	long long ans = 0;
	for (int i = 1; i <= N; ++i) {
		cin >> nh;
		line[i] = nh - bh;
		ans += ct(line[i]);
		bh = nh;
	}
	int fr, to, ho;
	for (int i = 0; i < Q; ++i) {
		cin >> fr >> to >> ho;
		ans -= ct(line[fr]);
		line[fr] += ho;
		ans += ct(line[fr]);
		if (to != N) {
			ans -= ct(line[to + 1]);
			line[to + 1] -= ho;
			ans += ct(line[to + 1]);
		}
		cout << ans << endl;
	}
	return 0;
}
long long ct(long long high) {
	long long res;
	if (high > 0) {
		res = (long long)high*S;
	}
	else {
		res = (long long)high*T;
	}
	return -res;
}

Measured memory_bytes: 4656
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <vector>

using namespace std;
long long y[1000];
int main() {
  long long x;
  cin>>x;
  for(long long i=0;i<800;i++){
      y[i]=i*i*i*i*i;
  }
  for(int i=0;i<800;i++){
      for(int j=0;j<800;j++){
          if(y[i]-y[j]==x){
              cout<<i<<" "<<j<<endl;
              return 0;
          }
          if(y[i]+y[j]==x){
              cout<<i<<" "<<-j<<endl;
              return 0;
          }
      }
  }
  return 0;
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define vi vector<int>
#define LLMAX 4000000000000000000LL
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
struct edge
{
	int t, f, w;
	bool operator < (const edge& e) const
	{
		return w > e.w;
	}
	edge(int from, int to, int weight)
	{
		t = to;
		f = from;
		w = weight;
	}
};
#define pll pair<ll,ll>
#define ii pair<int,int>
#define MOD 1000000007
const double EPS = (1e-5);
long long binpow(long long a, long long b){long long res = 1;while (b > 0){if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
int findXOR(int n){switch (n % 4){case 0:return n;case 1:return 1;case 2:return n + 1;case 3:return 0;}}
int rangeXOR(int l, int r){return (findXOR(l - 1) ^ findXOR(r));}
int getbit(int mask, int bit){return (mask & (1 << bit));}void setbit(int& mask, int bit, int val){if (val)mask |= (1 << bit);else mask &= ~(1 << bit);}
//ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
//ll lcm(ll a, ll b){return a * (b / gcd(a, b));}
const int N = 2e5+2;
const int M = 26;
const ll INF = N;
void solve()
{
	int k, a, b;
	cin >> k >> a >> b;
	int have = b / k - (a - 1) / k;
	if (have > 0)
		cout << "OK\n";
	else
		cout << "NG\n";
}
int main(void)
{
	//freopen("commandos.in", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	//scanf("%d", &tc);
	while (tc--)
	{
		solve();
	}
}

Measured memory_bytes: 3640
a = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
abss = float('inf')
chiten = 1
for i in range(a):
    bass = abs(b[0]-0.006*c[i]-b[1])
    if bass < abss:
        abss = bass
        chiten = i + 1
print(chiten)


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdlib>
#define ll long long
using namespace std;
int main()
{
    int D;
    scanf("%d",&D);
    printf("Christmas");
    int a=25-D;
    for(int i=0;i<a;i++)
    {
        printf(" Eve");
    }
    printf("\n");
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int size = s.size();
    rep(i, size){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3616
n,k=map(int,input().split())
p=[]
for i in range(n):
    a,b=map(int,input().split())
    p.append([a,b])

p.sort()

ans=0
for i in range(n):
    ans += p[i][1]
    if ans >= k:
        print(p[i][0])
        break

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++)cin >> v[i];
	int cnt=0;
	int max1=0;
	for(int i=0;i<n-1;i++){
		if(v[i+1]<=v[i])
		  cnt++;
		else{
		  max1=max(max1,cnt);
		  cnt=0;
			
		}
	}
	if(cnt>=1)max1=max(max1,cnt);
    cout << max1;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

	int n, l;
	int wk;
	cin >> n >> l;

	

	int min, max;

	min = l;
	max = l + n - 1;

	int sa;

	if (min > 0) {
		sa = min;
	}
	else if (max < 0) {
		sa = max;
	}
	else {
		sa = 0;
	}
	

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (l + i);
	}

	ans -= sa;

	cout << ans << endl;



	








}



Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  char s[5];
  scanf("%s",s);
  if(s[0]=='A' && s[1]=='A' && s[2]=='A'){
    printf("No\n");
  }else if(s[0]=='B' && s[1]=='B' && s[2]=='B'){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

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

int main(){
    int N,Q;
    int64_t K;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    vector<int64_t> point(N,K);
    for(int i = 0; i < Q; i++) cin >> A.at(i);
    for(int i = 0; i < Q; i++){
        int winner = A.at(i) - 1;
        point.at(winner)++;
    }
    for(int i = 0; i < N; i++){
        point.at(i) = point.at(i) - Q;
    }

    for(int i = 0; i < N; i++){
        if (point.at(i) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1792
n=int(input())
ans=sum((n-l+1)*(n-l+2)//2 for l in range(1,n+1))
for i in range(n-1):
    a,s=map(int,input().split())
    if a>s:a,s=s,a
    ans-=a*(n+1-s)
print(ans)

Measured memory_bytes: 9092
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M,sum=0;
    cin>>N>>M;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
        sum+=A[i];
    }
    sort(A,A+N);
    cout<<(A[N-M]>=(double)sum/(4*M)?"Yes":"No")<<endl;
    return 0;
}

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

using namespace std;

int N;
vector<int> P;
vector<int> Q;

inline int f(const vector<int>& v)
{
	int ret=1;
	vector<int> tmp(N);
	for (int i=0; i<N; i++) tmp[i]=i+1;
	for (; tmp!=v; ret++) next_permutation(tmp.begin(),tmp.end());
	return ret;
}

int main()
{
	cin >> N;
	for (int i=1; i<=N; i++)
	{
		int tmp;
		cin >> tmp;
		P.push_back(tmp);
	}
	for (int i=1; i<=N; i++)
	{
		int tmp;
		cin >> tmp;
		Q.push_back(tmp);
	}
	cout << abs(f(P)-f(Q)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
  int x,a;
  cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            if (ReadInt() < 1200) Println("ABC");
            else Println("ARC");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
#define rep(i,a,b) for(i=a;i<b;i++)
using namespace std;
int main(void)
{
	int n,i,j,k,suma,sumb,a,b;
	while(1) {
		cin>>n;if(n==0) break;
		suma=0,sumb=0;
		rep(i,0,n) {
			cin>>a>>b;
			if(a>b) suma+=a+b;
			else if(b>a) sumb+=a+b;
			else suma+=a,sumb+=b;
		}
		cout<<suma<<" "<<sumb<<endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
long long a(vector<long long> A){
  return max({A[0],A[1],A[2]})-min({A[0],A[1],A[2]});
}
int main(){
  long long H,W;
  cin>>H>>W;
  if(H%3==0 || W%3==0)
    cout<<0<<endl;
  else{
    long long i=100000000;
    for(int j=0;j<2;j++){
      i=min(i,a({(W/3+1)*H,(W-W/3-1)*(H/2),(W-W/3-1)*((H+1)/2)}));
      swap(W,H);
    }for(int j=0;j<2;j++){
      i=min(i,a({(W/3)*H,(W-W/3)*(H/2),(W-W/3)*((H+1)/2)}));
      swap(W,H);
    }
    cout<<min({i,H,W})<<endl;
  }
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Diagnostics;

namespace test
{

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<string> list = new List<string>();

            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                List<int> triangle = new List<int>();

                foreach (string st in s)
                {
                    triangle.Add(int.Parse(st));
                }

                triangle.Sort();

                list.Add(JudgeTriangle(triangle));
            }

            foreach (string s in list)
            {
                Console.WriteLine(s);
            }

        }

        static string JudgeTriangle(List<int> l)
        {
            if (l[2] * l[2] == l[1] * l[1] + l[0] * l[0])
            {
                return "YES";
            }
            else
            {
                return "NO";
            }

        }

    }
        
}

Measured memory_bytes: 5644
//2017-11-6
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (200000+5)

int n, nn, a[N], num[N];

bool Check(int nv){
//	printf("nv = %d\n", nv);
	For(i, 1, nn) num[i] = a[i] >= nv;
	//For(i, 1, nn) printf("%d ", num[i]); puts("");

	int me = num[n], l = n, r = n;
	while(l > 1 && r < nn){
		--l, ++r;
	//	printf("me = %d (%d %d) %d %d\n", me, l, r, num[l], num[r]);
		if(num[l] == me || num[r] == me) return me;
		
		me ^= 1;
	}
	return me;
}

void Solve(){
	int L = 1, R = nn, mid;
	while(L < R){
		mid = (L+R+1) >> 1;
		
	//	printf("Check(%d) = %d\n", mid, Check(mid));
		if(Check(mid)) L = mid;
		else R = mid-1;

	//	puts("========================");
	}

	printf("%d\n", L);
}

int main(){
	scanf("%d", &n); nn = n*2 - 1;
	For(i, 1, nn) scanf("%d", &a[i]);
	
	Solve();

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl


int main() {
  string S;
  getline(cin, S);

  stack<int> st;
  int num = -1;
  for (auto it = S.begin(); it != S.end(); ++it) {
    char c = *it;
    if (c == ' ') {
      if (num != -1)
        st.push(num);
      num = -1;
      continue;
    }
    if (c == '+') {
      int b = st.top(); st.pop();
      int a = st.top(); st.pop();
      st.push(a + b);
    } else if (c == '-') {
      int b = st.top(); st.pop();
      int a = st.top(); st.pop();
      st.push(a - b);
    } else if (c == '*') {
      int b = st.top(); st.pop();
      int a = st.top(); st.pop();
      st.push(a * b);
    } else {
      if (num == -1)
        num = 0;
      num *= 10;
      num += c-'0';
    }
  }
  if (num != -1)
    st.push(num);
  OUT(st.top());

  return 0;
}



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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    int ans = 0;
    REP(i, N) {
        if (h[i] < K) continue;
        ans += 1;
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;

// Caracal vs Monster

int main() {

	long long int h,cnt=0,sum=0;
	cin >> h;

	while (true)
	{
		if (h == 1) {
			sum = 1;
			break;
		}
		h /= 2;
		sum += pow(2, cnt);
		cnt++;
		if (h == 1) {
			sum += pow(2, cnt);
			break;
		}
		
	}

	cout << sum;

	return 0;
}

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

using namespace std;

int main(void) {
  int N, K; cin >> N >> K;
  bool have[N];
  memset(have, false, sizeof(have));

  for (int i = 0; i < K; i++) {
    int d; cin >> d;
    for (int j = 0; j < d; ++j) {
      int a; cin >> a;
      have[a-1] = true;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (!have[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632