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

int main(){
  int n,q,i,key,lb,ub,mid;
  int S[100000],ans = 0;

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" , S + i);
  }

  scanf("%d" ,&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d" ,&key);
    lb = 0; ub = n;
    while(ub >= lb){
      mid = (lb + ub) / 2;

      if(S[mid] == key){
	ans++;
	break;
      }

      if(S[mid] < key){
	lb = mid+1;
      }else{
	ub = mid-1;
      }
    }
  }
  printf("%d\n" ,ans);

  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,cmpp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> s;
       n=s.size();
       ans=n;
       rep(i,n-1){
           if(s[i]!=s[i+1]){
               ans=min(max(i+1,n-i-1),ans);
           }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
p = LIST()

ans = 0
for i in range(N):
	if p[i] == i+1:
		ans += 1
		if i < N-1:
			p[i+1] = "_"

print(ans)


Measured memory_bytes: 15960
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

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

    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];

    int cur = p[0];
    int ans = 1;
    rep(i, 1, n) {
        if (cur > p[i]) {
            cur = p[i];
            ans++;
        }
    }

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

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
    int Q, H, S, D;
    cin >> Q >> H >> S >> D;
    int N;
    cin >> N;
    int A = 0;
    A = min(4 * Q, 2 * H);
    A = min(A, 2 * Q + H);
    A = min(A, S);
    ll res = 0LL;
    if (2 * A <= D){ 
        res = (ll)N * A;
    } else {
        res = (ll)D * (N / 2LL) + (N % 2 != 0 ? (ll)A : 0LL);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  vector<string> v;
  string s,t;
  cin>>s>>t;
  rep(i,s.size()-t.size()+1){
    string tmp=s.substr(i,t.size());
    bool flag=true;
    rep(j,t.size()) if(!(t[j]==tmp[j] || tmp[j]=='?')) flag=false;
    if(flag){
      string ans=s.substr(0,i)+t+s.substr(i+t.size());
      rep(j,ans.size()) if(ans[j]=='?') ans[j]='a';
      v.push_back(ans);
    }
  }
  if(v.size()!=0){
    sort(ALL(v));
    cout<<v[0]<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    int A[200000];
    int Ac[200000];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        A[i] = a;
        Ac[i] = a;
    }

    sort(Ac, Ac + n);
    int max_first = Ac[n - 1];
    int max_second = Ac[n - 2];

    for (int i = 0; i < n; i++) {
        if (A[i] == max_first) {
            cout << max_second << endl;
        }
        else {
            cout << max_first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
while(True):
    n = int(input())
    if n == 0:
         break
    oe = []
    for i in range(n):
        e,p,q = map(int, input().split())
        for a in oe:
            if a[0] == e:
                a[1] += p*q
                continue
        oe.append([e,p*q])
    lis = [ a[0] for a in oe if a[1] >= 1000000]
    if len(lis):
        print("\n".join(str(l) for l in lis))
    else:
        print("NA")


Measured memory_bytes: 5636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

char s[100005];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    int cnt = 1;
    for (int i = 0; i < n; ++i) {
        if (i > 0 && s[i] != s[i - 1]) {
            ++cnt;
        }
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int x,y;cin>>x>>y;
  if(x==y && x == 1){
    cout << 1000000 << endl;
  }else{
    int ans = 0;
    if(x == 1)ans += 300000;
    else if(x == 2)ans += 200000;
    else if(x == 3)ans += 100000;

    if(y == 1)ans += 300000;
    else if(y == 2)ans += 200000;
    else if(y == 3)ans += 100000;
    cout << ans << endl;
  }
}

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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	// 電球M個に対するスイッチの配列
	vector<vector<int>> s(M);
	for (int i = 0; i < M; i++)
	{
		int k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int switchValue;
			cin >> switchValue;
			// switchの値から-1で配列のindexにする
			switchValue--;
			// 電球i番目におけるswitchの値の格納
			s[i].push_back(switchValue);
		}
	}
	// 余りの配列
	vector<int> p(M);
	for (int i = 0; i< M; i++)
	{
		cin >> p[i];
	}
	
	long answer = 0;
	
	// スイッチNの{0, 1, ..., n-1} の部分集合の全探索
	// bit全検索
	// 1<<Nは2の2のN乗
	for (int bit = 0; bit < (1<<N); bit++)
	{
		bool isLightOn = true;
		// 電球M個
		for (int i = 0; i < M; i++)
		{
			int onSwitchCount = 0;
			
			for (vector<int>::iterator it = s[i].begin(); it != s[i].end(); it++)
			{
				// 列挙に j が含まれるか
				// 2の(*it(switchの値))乗
				if (bit & (1<<*it)) {
					onSwitchCount++;
				}
			}
			// Onのスイッチの個数を2で割った余りが piに等しくない場合
			if (onSwitchCount % 2 != p[i])
			{
				// 点灯しない
				isLightOn = false;
			} 
		}
		
		// 全ての電球が点灯した
		if (isLightOn)
		{
			answer++;
		}
	}
	
	// 出力 (全ての電球が点灯するようなスイッチの on/off の状態の組み合わせ)
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>
#include <memory>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
   
    struct S {
        int y, i;
    };
    
    vector<vector<S>> c(n);
    
    for (int i = 0; i < m; i++) {
        int p;
        S s;
        
        cin >> p >> s.y;
        s.i = i;
        
        c[p - 1].push_back(s);
    }
    
    vector<pair<int, int>> ans(m);
    
    for (int i = 0; i < n; i++) {
        sort(c[i].begin(), c[i].end(), [](auto x, auto y) {
            return x.y < y.y;
        });
        
        for (int j = 0; j < c[i].size(); j++) {
            ans[c[i][j].i] = make_pair(i + 1, j + 1);   
        }
    }
    
    for (int i = 0; i < m; i++) {
        printf("%06d%06d\n", ans[i].first, ans[i].second);   
    }
}

Measured memory_bytes: 7808
N = int(input())
array = list(map(int, input().split()))
test = list(array)
test.sort()
wow = test[int(N / 2) - 1: int(N / 2) + 1]
for i in range(0, N):
    if array[i] > wow[0]:
        print(wow[0])
    else:
        print(wow[1])


Measured memory_bytes: 26180
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005

void solve(){
   int n,k;
   cin >> n >> k;
   int i,a[n+1],ans=0;
   for(i=1; i<=n; i++)cin >> a[i];
   sort(a+1,a+n+1);
   for(i=1; i<=k; i++){
       ans+=a[i];
   }
   cout << ans << '\n';
}




int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int tt;
        tt=1;
    //    cin >> tt;
        while(tt--){
            solve();
        }
        

}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;

int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n),ans(n,0);
	rep(i,n)std::cin >> a[i];
	ans[0]=0;
	ans[1]=abs(a[1]-a[0]);
	for (int i = 2; i < n; i++) {
		/* code */
		ans[i]=min(ans[i-2]+abs(a[i]-a[i-2]),ans[i-1]+abs(a[i]-a[i-1]));
	}
	std::cout << ans[n-1] << std::endl;
}







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

#define endl '\n'



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

    int n, h;
    cin >> n >> h;
    int mx = 0;
    vector <int> A(n);
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x >> A[i];
        mx = max(mx, x);
    }
    sort(A.begin(), A.end(), greater<int>());
    
    int res = 0;
    int i = 0;
    while(true) {
        if(h <= 0 || A[i] < mx || i >= A.size()) {
            break;
        }
        h -= A[i];
        i++;
        res++;
    }
    if(h > 0)
        res += (h / mx) + (h % mx > 0 ? 1 : 0);
    cout << res;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
D = {}

for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
s = 0
for j in D:
  s += j * D[j]
for i in range(Q):
  bi, ci = map(int, input().split())
  if bi in D:
    if ci in D:
      D[ci] += D[bi]
    else:
      D[ci] = D[bi]
    s += (ci - bi) * D[bi]
    del D[bi]
  print(s)

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

using namespace std;

int main(void)
{
	string s; cin>>s;
	int n; n = s.size();
	bool flag[4]; for(int i = 0; i < 4; i++) flag[i] = false;
	for(int i = 0; i < n; i++){
		if(s[i] == 'N') flag[0] = true;
		else if(s[i] == 'S') flag[1] = true;
		else if(s[i] == 'W') flag[2] = true;
		else if(s[i] == 'E') flag[3] = true;
	}
	if(flag[0] == true && flag[1] == false){
		cout<<"No"<<endl;
	}
	else if(flag[1] == true && flag[0] == false){
		cout<<"No"<<endl;
	}
	else if(flag[2] == true && flag[3] == false){
		cout<<"No"<<endl;
	}
	else if(flag[2] == false && flag[3] == true){
		cout<<"No"<<endl;
	}
	else cout<<"Yes"<<endl;
	/*
	cout<<"s = "<<s<<endl;
	for(int i = 0; i < 4; i++){
		cout<<"i = "<<i<<", flag[i] = ";
		if(flag[i] == true) cout<<"true"<<endl;
		else cout<<"false"<<endl;
	}
	*/
	return 0;
}



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

int main() {
    int n, h, w; scanf("%d%d%d", &n, &h, &w);
    vector<tuple<int, int, int>> edge;
    for (int i = 0; i < n; ++i) {
        int r, c, a; scanf("%d%d%d", &r, &c, &a);
        r--, c--;
        edge.emplace_back(a, r, c + h);
    }
    vector<int> uf(h + w), ec(h + w), sz(h + w);
    for (int i = 0; i < h + w; ++i) uf[i] = i, sz[i] = 1;

    function<int(int)> Find = [&](int x) {
        if (x == uf[x]) return x;
        return uf[x] = Find(uf[x]);
    };

    sort(edge.begin(), edge.end(), greater<tuple<int, int, int>>());
    long long ans = 0;
    for (auto &e : edge) {
        int w, u, v;
        tie(w, u, v) = e;
        u = Find(u), v = Find(v);
        if (u != v) {
            if (ec[v] == sz[v] && ec[u] == sz[u]) continue;
            uf[u] = v;
            ec[v] += ec[u] + 1;
            sz[v] += sz[u];
            ans += w;
        } else {
            if (ec[u] < sz[u]) {
                ec[u]++;
                ans += w;
            }
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = 1;
  FOR(i, 1, n) {
    if (s[i - 1] != s[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define    x            real()
#define    y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<double>
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
vector< pair<int,int> > v;
int main(){
    GO();
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int no;
        cin>>no;
        v.pb(mp(no,i+1));
    }
    sort(all(v));
    for(int i=0;i<sz(v);i++){
        if(i==0)
        cout<<v[i].second;
        else
        cout<<" "<<v[i].second;
    }
    cout<<endl;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n) break;
    vector<pair<double,int>> vp;
    REP(i,n){
      double t;
      int c;
      cin>>t>>c;
      vp.emplace_back(t,c);
    }
    sort(ALL(vp));
    vector<int> rem(n);
    queue<pair<int, double>> q1, q2;
    REP(i,n) {
      double t;
      int c;
      tie(t,c) = vp[i];
      q1.emplace(i, 0);
      rem[i] = c;
    }
    int last_updated = 0;
    while(!q1.empty() || !q2.empty()) {
      bool use_q1 = q2.empty();
      if (q1.empty()) use_q1 = false;
      if (!q1.empty() && !q2.empty()) {
        int i1,i2;
        double t1,t2;
        tie(i1,t1) = q1.front();
        tie(i2,t2) = q2.front();
        if (vp[i1].first + t1 <= vp[i2].first + t2) use_q1 = true;
        else use_q1 = false;
      }
      if (!use_q1) {
        int i;
        double t;
        tie(i,t) = q2.front();
        double nt = t + vp[i].first;
        vector<int> vi(1, i);
        q2.pop();
        while(!q2.empty()) {
          int j;
          double u;
          tie(j,u) = q2.front();
          double nu = u + vp[j].first;
          if (nu > nt) break;
          vi.push_back(j);
          q2.pop();
        }
        sort(ALL(vi));
        for(int i:vi) {
          last_updated = nt;
          --rem[i];
          if (rem[i]) q1.emplace(i, nt);
        }
      } else {
        int i;
        double t;
        tie(i,t) = q1.front();
        double nt = t + vp[i].first;
        vector<int> vi(1, i);
        q1.pop();
        while(!q1.empty()) {
          int j;
          double u;
          tie(j,u) = q1.front();
          double nu = u + vp[j].first;
          if (nu > nt) break;
          vi.push_back(j);
          q1.pop();
        }
        sort(ALL(vi));
        for(int i:vi)q2.emplace(i, nt);
      }
    }
    cout << last_updated << endl;
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

vector<ll> d;
pair<ll, ll> pp[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%lld%lld", &pp[i]._1, &pp[i]._2);
	}
	REP(i, 1, n) {
		if (abs(pp[i]._1 + pp[i]._2) % 2 != abs(pp[0]._1 + pp[0]._2) % 2) {
			printf("-1\n");
			return;
		}
	}
	ll a = 1ll << 30;
	for(; a > 1; a /= 2) {
		d.pb(a);
	}
	REP(i, 0, 6) {
		d.pb(1);
	}
	if (abs(pp[0]._1 + pp[0]._2) % 2 == 1) {
		d.pb(1);
	}
	printf("%d\n", SZ(d));
	REP(i, 0, SZ(d)) {
		printf("%lld ", d[i]);
	}
	putchar('\n');
	REP(i, 0, n) {
		ll curx = 0, cury = 0;
		REP(j, 0, SZ(d)) {
			ll vvx = pp[i]._1 - curx, vvy = pp[i]._2 - cury;
			if (abs(vvx) > abs(vvy)) {
				if (pp[i]._1 > curx) {
					putchar('R');
					curx += d[j];
				} else {
					putchar('L');
					curx -= d[j];
				}
			} else {
				if (pp[i]._2 > cury) {
					putchar('U');
					cury += d[j];
				} else {
					putchar('D');
					cury -= d[j];
				}
			}
		}
		putchar('\n');
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

ll dp[1000][1000];//dp[i][j]...マス(i, j)にたどり着くつきかた

int main()
{
	string a[1000];
	ll ans=0;
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>a[i];
	
	fill(dp[0],dp[1000],0);
	dp[0][0]=1;
	//ここからDP
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(a[i][j]=='#')
				continue;
			if(i!=0)
			{
				dp[i][j]+=dp[i-1][j];
				dp[i][j]%=MOD;
			}
			if(j!=0)
			{
				dp[i][j]+=dp[i][j-1];
				dp[i][j]%=MOD;
			}
		}
	}
	//ここまでDP
	ans=dp[h-1][w-1];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9088
/******************************************
* AUTHOR : Ashish Joshi* 
* INSTITUTION : NIT Hamirpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;

#define N 100005
#define MOD 1000000007
#define PI 3.141592653589793

#define dd double
#define loop(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define set(b,i) (b|(1<<i))
#define unset(b,i) (b&!(1<<i))
#define cbit(b,i) bool(b&(1<<i))

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n;
cin>>n;
ll h[n][3];
for(int i=0;i<n;i++)
	cin>>h[i][0]>>h[i][1]>>h[i][2];
ll dp[n][3]={0};
dp[0][0]=h[0][0];
dp[0][1]=h[0][1];
dp[0][2]=h[0][2];
for(int i=1;i<n;i++){
		
	dp[i][0]=h[i][0]+max(dp[i-1][1],dp[i-1][2]);
	dp[i][1]=h[i][1]+max(dp[i-1][0],dp[i-1][2]);
	dp[i][2]=h[i][2]+max(dp[i-1][0],dp[i-1][1]);
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;


return 0;
}

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


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

  int m = n;
  int count = 0;
  int ans = 0;

  while(m != 0){
    count += 1;
    m /= 10;
  }

  if(count%2!=0){
    ans += n - pow(10, count-1) + 1; 
  }

  for(int i=1; i<count; i++){
    if(i%2!=0){
      ans = ans + 9*pow(10,i-1);
    }
  }

  cout << ans <<endl;

}


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

using namespace std;

string X, Y;
int M[1001][1001];

int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> X >> Y;
		for (int i = 0; i <= X.length(); i++) {
			for (int j = 0; j <= Y.length(); j++) {
				M[i][j] = 0;
			}
		}
		for (int i = 0; i < X.length(); i++) {
			for (int j = 0; j < Y.length(); j++) {
				if (X[i] == Y[j]) M[i + 1][j + 1] = max(M[i + 1][j + 1], M[i][j] + 1);
				M[i + 1][j + 1] = max(M[i + 1][j + 1], M[i + 1][j]);
				M[i + 1][j + 1] = max(M[i + 1][j + 1], M[i][j + 1]);
			}
		}
		cout << M[X.length()][Y.length()] << endl;
	}
}


Measured memory_bytes: 6984
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int C = sc.nextInt();
			
			final long X = sc.nextInt();
			final long Y = sc.nextInt();
			
			long all = A * X + B * Y;
			//System.out.println(all);
			
			for(int i = 1; i <= Math.min(X, Y); i++){
				if(A + B > 2 * C) {
					all += 2 * C;
					all -= A + B;
				}
			}
			//System.out.println(all);
			
			for(int i = 1; i <= Math.abs(X - Y); i++) {
				//System.out.println(i + " " + B + " " + (2 * C));
				if(X < Y){
					if(B > 2 * C) {
						all += 2 * C;
						all -= B;
					}
				}else {
					if(A > 2 * C){
						all += 2 * C;
						all -= A;
					}
				}
			}
			
			System.out.println(all);
			
			/*/
			try(final PrintWriter pw = new PrintWriter(System.out)){
				pw.printf("%.8f\n", (double)(answer) / all_pairs);
			}
			//*/
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){ ret[i] = this.nextInt();}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++) { ret[i] = this.nextLong();}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 1000000007;

vector <int> G[101010];
int H[101010];
int n, m, ans;
int32_t main()
{
    usecppio
    cin >> n >> m;
    for (int i = 1; i<=n; i++) cin >> H[i];
    for (int i = 0; i<m; i++)
    {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for (int i = 1; i<=n; i++)
    {
        bool good = true;
        for (auto it:G[i])
        {
            if (H[i] <= H[it])
                good = false;
        }
        ans += good;
    }
    cout << ans;
}

Measured memory_bytes: 10268
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.*;


public class Main {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static StringBuilder sb = new StringBuilder("");

    static int[] inputArray(int n) throws IOException {
        int[] a = new int[n];
        st = new StringTokenizer(br.readLine());
        for(int i = 0 ; i < n ; i++) {
            a[i] = Integer.parseInt(st.nextToken());
        }
        return a;
    }

    static long modExpo(long x , long y , int mod){
        long res = 1;
        for(long i = 0 ; i < y ; i++){
            res = res * x % mod;
        }
        return res;
    }


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        long n = Long.parseLong(br.readLine());
        int m = (int)1e9 + 7;
        long a1 = modExpo(10 , n , m);
        long a2 = modExpo(9 , n , m);
        long a3 = modExpo(8 , n , m);
        //System.out.println(a1 + " " + a2 + " " + a3);
        System.out.println((a1 - 2*a2 % m + a3 + m) % m);
    }

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

    static void longestGcdSeq(int a[] , int n) {
        int coprimes[] = new int[n];
        for(int i = 0 ; i < n ; i++) {
            if(a[i] < a[(i+1)%n]) {
                if(gcd(a[(i+1)%n] , a[i]) != 1) {
                    coprimes[i] = 1;
                }
            }
            else {
                if(gcd(a[i] , a[(i+1)%n]) != 1) {
                    coprimes[i] = 1;
                }
            }
        }
        //System.out.println(Arrays.toString(coprimes));
        int maxLen = 0 , startLen = 0 , endLen = 0;
        int i = 0;
        while(i < n && coprimes[i] == 1) {
            startLen++;
            i++;
        }
        i = n -1;
        while(i >= 0 && coprimes[i] == 1) {
            endLen++;
            i--;
        }
        int start = 0;
        for(i = 0 ; i < n ; i++) {
            if(coprimes[i] == 0) {
                maxLen = Math.max(maxLen , i - start);
                start = i + 1;
            }
        }
        maxLen = Math.max(maxLen , i - start);
        start = i + 1;
        //System.out.println(startLen + " " + maxLen + " " + endLen);
        int contMax = startLen == n ? n : Math.max(startLen + endLen , maxLen) + 1;
        //System.out.println(contMax);
        for(int k = 2 ; k <= n ; k++) {
            System.out.print((contMax-1)/(k-1) + " ");
        }
        System.out.println();
    }

}
/*

if(tree.size == 2) {

}

5 8
5 1 2 4 3
0 1
0 2
0 3
0 4
0 5
1 1000000000
1 1
1 500000000


 */

Measured memory_bytes: 32860
package main

import (
	"fmt"
	"strings"
)

func main() {
	letters := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	var s string
	fmt.Scan(&s)

	if len(s) < 26 {
		ret := s
		for _, v := range letters {
			if !strings.Contains(s, v) {
				ret += v
				break
			}
		}
		fmt.Println(ret)
		return
	} else {
		startSuffix := len(s) - 1
		for i := len(s) - 1; i >= 1; i-- {
			if s[i-1] < s[i] {
				break
			}
			startSuffix--
		}
		if startSuffix == 0 {
			fmt.Println(-1)
			return
		}
		qIndex := startSuffix
		target := s[startSuffix-1]
		for i := startSuffix; i < len(s); i++ {
			if s[i] > target && s[i] < s[qIndex] {
				qIndex = i
			}
		}
		fmt.Println(s[:startSuffix-1] + s[qIndex:qIndex+1])
		return
	}
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DWeLoveABC solver = new DWeLoveABC();
        solver.solve(1, in, out);
        out.close();
    }

    static class DWeLoveABC {
        private static final int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            String s = in.string();
            int n = s.length();

            long[] pow = new long[n + 1];
            pow[0] = 1;
            for (int i = 1; i <= n; i++) {
                pow[i] = (pow[i - 1] * 3) % MOD;
            }

            int[] a = new int[n + 2];
            int[] c = new int[n + 2];
            int[] q = new int[n + 2];
            for (int i = 0; i < n; i++) {
                a[i + 1] = a[i] + (s.charAt(i) == 'A' ? 1 : 0);
                c[i + 1] = c[i] + (s.charAt(i) == 'C' ? 1 : 0);
                q[i + 1] = q[i] + (s.charAt(i) == '?' ? 1 : 0);
            }
            a[n + 1] = a[n];
            c[n + 1] = c[n];
            q[n + 1] = q[n];

            long ans = 0;
            for (int i = 0; i < n; i++) {
                int d = q[n + 1];
                if (s.charAt(i) == 'A' || s.charAt(i) == 'C') {
                    continue;
                } else if (s.charAt(i) == '?') {
                    d--;
                }
                ans += pow[d] * a[i] * (c[n + 1] - c[i + 1]);
                ans %= MOD;
                ans += pow[Math.max(d - 1, 0)] * a[i] * (q[n + 1] - q[i + 1]);
                ans %= MOD;
                ans += pow[Math.max(d - 1, 0)] * q[i] * (c[n + 1] - c[i + 1]);
                ans %= MOD;
                ans += pow[Math.max(d - 2, 0)] * q[i] * (q[n + 1] - q[i + 1]);
                ans %= MOD;
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll K;
	cin >> K;

	queue<ll> q;
	for (int ii = 1; ii < 10; ++ii){
		q.push(ii);
	}

	ll cnt = 0;
	ll ans;
	while (cnt < K) {
		ll val = q.front();	q.pop();
		ll val1 = val % 10;	//1の位
		for (ll ii = -1; ii < 2; ++ii){
			ll tmp = val1 + ii;
			if ( (0 <= tmp) && (tmp <= 9) ){
				q.push(val * 10 + tmp);
			}
		}
		ans = val;
		cnt++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  ll ans = 0;
  vector<int> p(N);
  REP(i, N) p[i] = i;
  do {
    if (p[0] != 0) continue;
    bool b = true;
    REP(i, N - 1) {
      bool t = false;
      REP(j, A[p[i]].size()) {
        if (A[p[i]][j] == p[i + 1]) t = true;
      }
      if (!t) b = false;
    }
    if (b) ans++;
  } while (next_permutation(p.begin(), p.end()));
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n+1,0);
    rep(i, 1, n+1)
        cin >> v[i];
    vector<int> dp(n+1,0);
    dp[2] = abs(v[2]-v[1]);
    rep(i, 3, n+1)
    {
        int p1 = dp[i-1] + abs(v[i]-v[i-1]);
        int p2 = dp[i-2] + abs(v[i]-v[i-2]);
        dp[i] = min(p1, p2);
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;cin>>N;
	set<char> t;
	rep(i,N){
		char c;
		cin>>c;
		t.insert(c);
	}
	cout<<((t.size() == 3)?"Three":"Four")<<endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())
ans = 0

for i in range(2**(len(s)-1)):
        b = bin(i)[2:].zfill(len(s)-1)
        tmp = s.copy()
        cc = 1
        for j in range(len(s)-1):
                if b[j]=="1":
                        tmp.insert(int(j)+cc, "+");
                        cc += 1
        ans += eval("".join(tmp))
print(ans)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

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

        if(A>=13 && A<=100 )
        {
            cout<<B;

        }
        else if(A<=12 && A>=6)
        {
            cout<<B/2<<endl;

        }
        else if (A>=0 && A<6)
        {
            cout<<0;

        }


    return 0;
}


Measured memory_bytes: 256
# not solved only by mysql

N,K = map(int,input().strip().split())

if K % 2 != 0:
    even = len([n for n in range(1,N + 1) if n % K == 0])
    print(even ** 3)
else:
    ks = len([n for n in range(1, N + 1) if n % K == 0])
    ks_half = len([n for n in range(1, N + 1) if n % K == K // 2 ])
    print(ks_half**3 + ks ** 3)


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int x = 0;
  rep(i, n) {
    cin >> a[i];
    x ^= a[i];
  }

  rep(i, n) cout << (x ^ a[i]) << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 4032
/*
https://atcoder.jp/contests/dp/tasks/dp_b
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 1;
int n, k;
ll h[N], f[N];

void Init ()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i) 
    {
        cin >> h[i];
        f[i] = 1e9 + 7;
    }
    f[0] = 0;
}

int main ()
{
    Init();
    for (int i = 1; i < n; ++i)
    {
        for (int j = max (0, i - k); j < i; ++j)
        {
            f[i] = min (f[i], f[j] + abs (h[i] - h[j]));
        }
    }
    cout << f[n - 1];
    return 0;
}

Measured memory_bytes: 5192
from decimal import Decimal
from decimal import *
a, b, c = map(str, input().split())

getcontext().prec = 50

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)

if a**Decimal("0.5")  + b**Decimal("0.5") < c**Decimal("0.5"):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5076
N = int(input())
List = list(map(int, input().split()))

i=0
while i<N:
    
    if List[i]%2==0:
        
        if List[i]%3==0 or List[i]%5==0:
            pass
        else:
            print("DENIED")
            quit()
        
    i+=1
    
print("APPROVED")



Measured memory_bytes: 2940
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.util.Arrays;
import java.util.stream.Collectors;

class Main {
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        
        // 読み込み
        while((line = stdin.readLine()) == null);
        
        Long result = 0L;
        for(Integer i = 0; i < 10;i++) {
            String replaced = line.replace(i.toString(), "");
            result += (line.length() - replaced.length()) * i;
            line = replaced;
        }
        
        System.out.println(result % 9 == 0 ? "Yes": "No");
    } catch(Exception e) {
    }
   
  }
}

Measured memory_bytes: 38068
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    ll t1, t2; cin >> t1 >> t2;
    ll a1, a2; cin >> a1 >> a2;
    ll b1, b2; cin >> b1 >> b2;
    ll p = a1*t1 - b1*t1;
    ll q = a2*t2 - b2*t2;
    if(p < 0){
        p *= -1;
        q *= -1;
    }
    if((p + q) > 0){
        cout << 0 << endl;
        return 0;
    }
    if((p + q) == 0){
        cout << "infinity" << endl;
        return 0;
    }
    ll s = p / (-1*(p+q));
    ll t = p % (-1*(p+q));
    if(t == 0) cout << 2*s << endl;
    else cout << 2*s + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int K,A[40],i;

int main()
{
  cin >>K;
  
  i=1;
  A[i]=1;
  i++;
  A[i]=1;i++;
  A[i]=1;i++;
  A[i]=2;i++;
  A[i]=1;i++;
  A[i]=2;i++;
  A[i]=1;i++;
    A[i]=5;i++;
   A[i]=2;i++;
    A[i]=2;i++;
    A[i]=1;i++;
    A[i]=5;i++;
    A[i]=1;i++;
    A[i]=2;i++;
    A[i]=1;i++;
    A[i]=14;i++;
    A[i]=1;i++;
    A[i]=5;i++;
    A[i]=1;i++;
    A[i]=5;i++;
    A[i]=2;i++;
    A[i]=2;i++;
    A[i]=1;i++;
    A[i]=15;i++;
    A[i]=2;i++;
    A[i]=2;i++;
    A[i]=5;i++;
   A[i]=4;i++;
    A[i]=1;i++;
    A[i]=4;i++;
    A[i]=1;i++;
    A[i]=51;i++;
  
  cout <<A[K];
  
}

Measured memory_bytes: 256
def solve():
    N, K = [int(_) for _ in raw_input().split()]
    if N == 1 or K == 1:
        ret = 1
    elif N % 2 == 0 or K % 2 == 0:
        ret = N * K /2
    else:
        ret = N * K /2 + 1
    print ret

if __name__ == '__main__':
    solve()


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

int main(){
    int n;
    cin>>n;
    int Min,pos;
    int arr[n];
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }

    int cnt=0;
    for(int i=0; i<n; i++){
        Min=i;
        for(int j=i; j<n; j++){
            if(arr[Min]>arr[j]) Min=j;
        }
        if(Min!=i){
            swap(arr[i],arr[Min]);
            cnt++;
        }
    }

    cout<<arr[0];
    for(int i=1; i<n; i++){
        cout<<" "<<arr[i];
    }
    cout<<endl<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 3116
#include <math.h>
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t H;
  cin >> H;
  int64_t times = 0;
  while (H) {
    times++;
    H /= 2;
  }
  int64_t answer = pow(2, times) - 1;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

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

	ll n,m;
	cin>>n>>m;
	char c[n][m];
	for(ll i=0;i<n;i++)
		for(ll j=0;j<m;j++)
			cin>>c[i][j];
	bool b[n][m];
	for(ll i=0;i<n;i++)
		for(ll j=0;j<m;j++)
			b[i][j]=0;
	queue <pair <ll,ll> > q;
	ll mx=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			if(c[i][j]=='.')
				{
					for(ll i=0;i<n;i++)
					for(ll j=0;j<m;j++)
							b[i][j]=0;
					q.push({i,j});
					b[i][j]=1;
					ll curr_lvl=1,nxt_lvl=0;
					ll temp=-1;
					while(!q.empty())
					{
						nxt_lvl=0;
						while(curr_lvl>0)
						{
							curr_lvl--;
							pll p=q.front();//cout<<p.f<<' '<<p.s<<' '<<b[p.f][p.s]<<endl;
							q.pop();
							if(p.f-1>=0 )
							if(b[p.f-1][p.s]==0 && c[p.f-1][p.s]!='#')
							{
								q.push({p.f-1,p.s});
								b[p.f-1][p.s]=1;
								nxt_lvl++;
							}
							if(p.f+1<n)
							if(b[p.f+1][p.s]==0 && c[p.f+1][p.s]!='#')
							{
								q.push({p.f+1,p.s});
								b[p.f+1][p.s]=1;
								nxt_lvl++;
							}
							if(p.s-1>=0)
							if(b[p.f][p.s-1]==0 && c[p.f][p.s-1]!='#')
							{
								q.push({p.f,p.s-1});
								b[p.f][p.s-1]=1;
								nxt_lvl++;
							}
							if(p.s+1<m)
							if(b[p.f][p.s+1]==0 && c[p.f][p.s+1]!='#')
							{
								q.push({p.f,p.s+1});
								b[p.f][p.s+1]=1;
								nxt_lvl++;
							}
						}
						curr_lvl=nxt_lvl;
						nxt_lvl=0;
						temp++;//cout<<-1;
						}
					mx=max(mx,temp);
				}
		}
	}
	cout<<mx<<'\n';
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1;i < n + 1;i++){
        int memo = 0;
        int j = i;
        while(true){
            memo += j % 10;
            j /= 10;
            if(j == 0)break;
        }
        if(a <= memo && memo <= b)ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3516
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	if( a + b + c >= 22 ) cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    string S;
    bool is=false;
    cin >>N>>S;
    is= (N%2==0);
    //-----------------------------------
    if(is){
        rep(i,N/2){
            if(S[i]!=S[N/2+i])is=false;
        }
    }
    cout << ((is) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256
using System;


namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            while (true)
            {
                int x = int.Parse(Console.ReadLine());
              

                if (x == 0 || 10000 < i)
                {
                    break;
                }

                Console.WriteLine("Case "+ i + ": " + x);
             i++;
            }
        }
    }
}

Measured memory_bytes: 9220