akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

vector<string> split(const string &str, char sep) {
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep)) {
        v.push_back(buffer);
    }
    return v;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        string s;
        cin >> s;
        vector<string> n = split(s, '/');
        if (stoi(n[1])<=4){
            cout<<"Heisei"<<endl;
        } else{
            cout<<"TBD"<<endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
xs = gets.chomp

# n = 200000
# xs = '11010110111100001010' * 10000

xi = xs.to_i(2)
init_count = xs.count('1')

xi_init = xi
xs_init = xs.dup

# p [xi_init, xs_init]

xi_init_m1 = xi_init % (init_count-1) if init_count > 1
xi_init_p1 = xi_init % (init_count+1)

anss=[]
hiku_m1 = 1
hiku_p1 = 1
n.times do |i|
  if xs_init[n-i-1] == '1'
    if init_count == 1
      anss.push 0
      next
    end
    count = init_count - 1
    # xi = xi_init_m1 - mod_kai(n-i-1, count)
    xi = xi_init_m1 - hiku_m1
  else
    count = init_count + 1
    # xi = xi_init_p1 + mod_kai(n-i-1, count)
    xi = xi_init_p1 + hiku_p1
  end

  # p [i, [xi, xi.to_s(2)], count]
  xi = (xi + count) % count

  xi %= count #=
  xs = xi.to_s(2)

  ans = 1
  while xi > 0
    count = xs.count('1')
    xi %= count #=
    xs = xi.to_s(2)
    ans += 1
  end
  hiku_m1 = hiku_m1 * 2 % (init_count-1) if init_count > 1
  hiku_p1 = hiku_p1 * 2 % (init_count+1)
  anss.push ans
end

anss.reverse_each do |e|
  puts e
end


Measured memory_bytes: 16956
#include <bits/stdc++.h>
#define LL long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 1e6 + 5;

//int a[N];


void solve() {

    string a;
    cin >> a;
    int n = a.size();
    if(n & 1) {
        puts("No");
        return ;
    }
    for(int i = 0; i < n; i += 2) {
        if(a[i] == 'h' && a[i + 1] == 'i') continue;
        puts("No"); return ;
    }
    puts("Yes");
    return ;
}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import bisect



def main():
    data = list(input())
    #
    # if data.count('W') == 0 or data.count('B') == 0:
    #     print(0)
    #     sys.exit()

    white, black = 0, 0

    pre = ''
    for i in range(len(data)):
        if pre == data[i]:
            continue
        pre = data[i]
        if data[i] == 'W':
            white += 1
        else:
            black += 1

    print(black+white - 1)



if __name__ == '__main__':
    main()

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

typedef pair<int, int>P;

int main(){
    int N;
    cin >> N;
    vector<P>vec;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(i%2==0)vec.push_back(P(i,a));
        else vec.push_back(P(-i, a));
    }
    sort(vec.begin(), vec.end());
    if(N%2)reverse(vec.begin(), vec.end());
    for(int i=0;i<N;i++){
        cout<<vec[i].second;
        if(i+1==N)cout<<endl;
        else cout << " ";
    }
    return 0;
}

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

#define pb         push_back

const int INF = 1000000000;
const int MOD = 1000000007;
const int MAX = 10000000;

bool prime[MAX];

void era(int n){
	for(int i=0; i<n; i++){
		if(i % 2 == 0){
			prime[i] = false;
		}else{
			prime[i] = true;
		}
	}
	prime[0] = prime[1] = false;
	prime[2] = true;

	for(int i=3; i*i <=n; i+=2){
		if(prime[i] == true){
			for(int j=2; i*j <= n; j++){
				prime[i*j] = false;
			}
		}
	}
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	era(MAX-1);

	while(1){
		int n, p;
		cin >> n >> p;
		if(n == -1 && p == -1) break;
		vector<int> plist;
		vector<int> M;
		
		for(int i=n+1; ; i++){
			if(prime[i]){
				plist.push_back(i);
			}
			if(plist.size() > 200) break;
		}

		for(int i=0; i<plist.size(); i++){
			for(int j=i; j<plist.size(); j++){
				M.push_back(plist[i] + plist[j]);
			}
		}
		sort(M.begin(), M.end());

		cout << M[p-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 12900
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

lli cnt = 0;
vector<lli> vis;
vector<vector<lli>> adj;

void dfs(lli a) {
    for (auto val : adj[a]) {
        if (vis[val] == 0) {
            vis[val] = 1;
            cnt++;
            dfs(val);
        }
    }
}

void solve() {
    lli n, a, m, b;
    cin >> n >> m;
    adj.resize(n + 2);

    for (lli i = 0; i < m; i++) {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    vis.resize(n + 2, 0);
    lli ans = 0;
    for (lli i = 1; i <= n; i++) {
        vis[i] = 1;
        cnt = 1;
        dfs(i);
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 21916
(defun solve (a b)
  (let ((c (* a 100/8))
        (d (* b 100/10)))
    (loop for x from (floor (min c d)) to (ceiling (max c d))
          if (and (= (floor (* x 8/100)) a)
                  (= (floor (* x 10/100)) b))
          do (return x)
          finally (return -1))))

#-swank
(let* ((a (read))
       (b (read)))
  (format t "~A~%" (solve a b)))


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

void BubbleSort(string C[],int N)
{
	for(int i=0;i<N;i++)
	{
		for(int j=N-1;j>i;j--)
		{
			if(C[j][1]<C[j-1][1])
			{
				swap(C[j],C[j-1]);
			}
		}
	}
}

void SelectionSort(string C[],int N)
{
	for(int i=0;i<N;i++)
	{
		int minj=i;
		for(int j=i;j<N;j++){
			if(C[j][1]<C[minj][1])
			{
				minj=j;
			}
		}
		swap(C[i],C[minj]);
	}
}

bool isStable(string in[],string out[],int N)
{
	for(int i=0;i<N;i++)
	{
		for (int j = i+1; j < N; j++)
		{
			for(int a=0;a<N;a++)
			{
				for(int b=a+1;b<N;b++)
				{
					if(in[i][1]==in[j][1]&&in[i]==out[b]&&in[j]==out[a])return false;
				}
			}
		}
		
	}
return true;
}

int main() 
{
	int N;cin>>N;
	string A[36];
	for(int i=0;i<N;i++)cin>>A[i];
	string B[36];
	for(int i=0;i<N;i++)B[i]=A[i];
	string in[36];
	for(int i=0;i<N;i++)in[i]=A[i];
	
	BubbleSort(A,N);
	for (int i = 0; i < N; i++)
	{
		if(i)cout<<" ";
		cout<<A[i];
	}cout<<endl;
	if(isStable(in,A,N))cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;

	SelectionSort(B,N);
	for (int i = 0; i < N; i++)
	{
		if(i)cout<<" ";
		cout<<B[i];
	}cout<<endl;
	if(isStable(in,B,N))cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
	
	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
struct Element
{
    int u,v,opt;
} p[N+3];
int fa[N+3];
ll c;

int find(int u) {return fa[u]==u?u:fa[u]=find(fa[u]);}

int main(){
    ll n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=q;i++){
        scanf("%d%d%d",&p[i].u,&p[i].v,&p[i].opt);
        p[i].u++;
        p[i].v++;
        if(p[i].opt==0){
            int fu=find(p[i].u),fv=find(p[i].v);
            if(fu!=fv)
                fa[fu]=fv;
        }
    }
    ll c=0;
    for(int i=1;i<=n;i++){
        if(find(i)==i)
            c++;
    }
    ll huan=0;
    for(int i=1;i<=q;i++){
        if(p[i].opt==1){
            huan++;
            if(find(p[i].u)==find(p[i].v)){
                printf("No\n");
                return 0;
            }
        }
    }
    ll temp=m-(n-c);
    ll l,r;
    l = huan?max(3ll,(ll)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(l<=temp&&temp<=r)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
const int N=2e5+10;
int a[N];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int j=1,ans=0;
	for(int i=0;i<n;i++){
		if(a[i]==j) j++;
		else ans++;
	}
	cout<<(j==1?-1:ans);
	return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<double, double> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

string debug_show(P a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}



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

	int N, M, K;
	cin >> N >> M >> K;
	K = N*M - K;
	rep(a, N+1) {
		rep(b, M+1) {
			if (M*a + N*b - 2 * a*b == K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

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

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=-1e9,num=0;
    if(n%2){
        ll index=-2;
        b[0]=b[n-1]=1;
        for(int i=1;i<n-1;i++){
            b[i]=index;
            index*=-1;
        }
        int idx=0;
        for(int i=1;i<n-1;i+=2){
            c[i]=b[i]*a[idx];
            idx++;
        }
        idx=n-1;
        for(int i=2;i<n-2;i+=2){
            c[i]=b[i]*a[idx];
            idx--;
        }
        c[0]=b[0]*a[idx];
        idx--;
        c[n-1]=b[n-1]*a[idx];
        for(int i=0;i<n;i++){
            num+=c[i];
        }
        ans=max(ans,num);
        for(int i=0;i<n;i++){
            b[i]*=-1;
        }
        idx=0;
        for(int i=2;i<n-2;i+=2){
            c[i]=b[i]*a[idx];
            idx++;
        }
        idx=n-1;
        for(int i=1;i<n-1;i+=2){
            c[i]=b[i]*a[idx];
            idx--;
        }
        c[0]=b[0]*a[idx];
        idx--;
        c[n-1]=b[n-1]*a[idx];
        num=0;
        for(int i=0;i<n;i++){
            num+=c[i];
        }
        ans=max(ans,num);
    }
    else{//3 1 4 1 5 9
        ll index=-2;
        b[0]=1;
        b[n-1]=-1;
        for(int i=1;i<n-1;i++){
            b[i]=index;
            index*=-1;
        }
        index=0;
        for(int i=1;i<n-1;i+=2){
            c[i]=b[i]*a[index];
            index++;
        }
        index=n-1;
        for(int i=2;i<n-1;i+=2){
            c[i]=b[i]*a[index];
            //if(i==4)cout <<b[i]<<" "<<a[index];
            index--;
        }
        c[0]=b[0]*a[index];
        index--;
        c[n-1]=b[n-1]*a[index];
        //cout << index<<endl;
        for(int i=0;i<n;i++){
            num+=c[i];
            //cout << i<<" "<<c[i]<<endl;
        }
        ans=max(ans,num);
        for(int i=0;i<n;i++){
            //cout << b[i]<<endl;
            b[i]*=-1;
        }
        index=0;
        num=0;
        for(int i=2;i<n-1;i+=2){
            c[i]=b[i]*a[index];
            //if(i==4)cout <<b[i]<<" "<<a[index];
            index++;
        }
        index=n-1;
        for(int i=1;i<n-1;i+=2){
            c[i]=b[i]*a[index];
            
            index--;
        }
        c[n-1]=b[n-1]*a[index];
        index--;
        c[0]=b[0]*a[index];
        //cout<<index<<endl;
        for(int i=0;i<n;i++){
            num+=c[i];
            //cout << i<<" "<<c[i]<<endl;
        }
        ans=max(ans,num);
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int main(void){
	int i,f=0,c,cp;
	string s;
	cin>>s;
	if(s[0]!='A'){
		f+=1;
	}
	c=0;
	for(i=2;i<s.length()-1;i++){
		if(s[i]=='C'){
			c++;
			cp=i;
		}
	}
	if(c!=1){
		f+=10;
	}
	for(i=1;i<s.length();i++){
		if(i!=cp){
			if(!(s[i]>='a'&&s[i]<='z')){
				f+=100;
			}
		}
	}
	if(f==0){
		cout<<"AC"<<endl;
	}
	else{
		cout<<"WA"<<endl;
	}
	return 0;
}


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

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

using namespace std;

typedef pair<int,int> ii;
const int IINF = INT_MAX;

vector<ii> G[100010];
int mincost[100010];
int V,E,r;

struct Data{
  int cur,cost;
  bool operator < (const Data& data) const{ return cost > data.cost; }
};

int main(){
  scanf("%d %d %d",&V,&E,&r);

  int s,t,d;
  rep(i,E){
    scanf("%d %d %d",&s,&t,&d);
    G[s].push_back(ii(t,d));
  }

  // Shortest Path Faster Algorithm 
  // O(kE)

  rep(i,V) mincost[i] = IINF;
  mincost[r] = 0;
  deque<int> deq; deq.push_back(r);
  vector<int> in_queue(V,0); in_queue[r] = 1;
  vector<int> time_stamp(V,0); time_stamp[r] = 1;

  bool found = false;
  while(!deq.empty()){
    int u = deq.front(); deq.pop_front(); in_queue[u] = 0;
    rep(i,(int)G[u].size()){
      int v = G[u][i].first, c = G[u][i].second;
      if( mincost[v] > mincost[u] + c ) {
        mincost[v] = mincost[u] + c;
        if( !in_queue[v] ) {
          deq.push_back(v);
          in_queue[v] = 1;
          time_stamp[v]++;
          if( time_stamp[v] >= V-2 ) {
            found = true;
            goto Skip;
          }
        }
      }
    }
  }
 Skip:;
  if( found ){
    puts("NEGATIVE CYCLE");
    return 0;
  }
  rep(i,V) {
    if( mincost[i] == IINF ) puts("INF");
    else printf("%d\n",mincost[i]);
  }

  return 0;
}

Measured memory_bytes: 3604
import heapq as h

N=int(input())
a=[0 for i in range(0,N-1)]
b=[0 for i in range(0,N-1)]
for i in range(0,N-1):
    a[i],b[i]=map(int,input().split())
hen=[[] for i in range(0,N+1)]
for i in range(0,N-1):
    hen[b[i]].append([a[i],i+1])
    hen[a[i]].append([b[i],i+1])

flag=[0 for i in range(0,N+1)]
ans=[0 for i in range(0,N)]

count=0
subcount=0
q=[]
h.heapify(q)
h.heappush(q,1)
sub=[]
h.heapify(sub)
while q!=[]:
    if q==[1]:
        subcount=0
        usedcolor=0
        x=h.heappop(q)
        for p in hen[x]:
            if flag[p[0]]==0:
                subcount+=1
                h.heappush(sub,p[0])
            else:
                colored=p[0]
                usedcolor=ans[p[1]]
        count=subcount
        color=1
        for p in hen[x]:
            if flag[p[0]]==0:
                if color!=usedcolor:
                    ans[p[1]]=color
                    color+=1
                else:
                    color+=1
                    ans[p[1]]=color
                    color+=1
        flag[x]=1
        q=sub
        sub=[]
        h.heapify(sub)

    else:
        while q!=[]:
            subcount=0
            colored=0
            usedcolor=0
            x=h.heappop(q)
            for p in hen[x]:
                if flag[p[0]]==0:
                    subcount+=1
                    h.heappush(sub,p[0])
                else:
                    colored=p[0]
                    usedcolor=ans[p[1]]
            if subcount>=count:
                count=subcount+1
            color=1
            for p in hen[x]:
                if flag[p[0]]==0:
                    if color!=usedcolor:
                        ans[p[1]]=color
                        color+=1
                    else:
                        color+=1
                        ans[p[1]]=color
                        color+=1
            flag[x]=1
            if q==[]:
                q=sub
                sub=[]
                h.heapify(sub)
                break
print(count)
for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 91952
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
    
A_sorted = sorted(A)
A_max1 = A_sorted[-1]
A_max2 = A_sorted[-2]

if A_max1 == A_max2:
    for i in range(N):
        print(A_max1)
else:
    max_idx = A.index(A_max1)
    for i in range(N):
        if i==max_idx:
            print(A_max2)
        else:
            print(A_max1)

Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<bl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.b()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<bl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll fib(ll n)
{
    if(n < 2)
        return n;
    ll a = 0,b = 1,ans;
    int i = 1;
    while(i < n)
    {
        ans = (a+b) % MOD;
        a = b;
        b = ans;
        i++;
    }
    return ans;
} 
int main()
  {
      fastio();
      int n,m;
      cin>>n>>m;
      int height[n+1];
      int mx[n+1];
      fill(mx,mx+n+1,0);
      height[0]=0;
      for(int i=1;i<=n;i++)
      {
          cin>>height[i];
      }
      for(int i=1;i<=m;i++)
      {
          int a,b;
          cin>>a>>b;
          mx[a]=max(mx[a],height[b]);
          mx[b]=max(mx[b],height[a]);
      }
      int count=0;
      for(int i=1;i<=n;i++)
      {
          if(height[i]>mx[i])
            count++;
      }
      cout<<count<<"\n";
      
  }


Measured memory_bytes: 4440
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;

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

        while (true) {
            boolean ans = true;
            String str = scanner.nextLine();
            if (str.equals(".")) break;

            Stack<Character> s = new Stack<>();

            for (int i = 0; i < str.length(); ++i) {
                char c = str.charAt(i);
                if (c == '(') s.push(c);
                else if (c == ')') {
                    if (s.empty() || s.pop() != '(') ans = false;
                }

                if (c == '[') s.push(c);
                else if (c == ']') {
                    if (s.empty() || s.pop() != '[') ans = false;
                }
            }

            System.out.println((s.empty() && ans ? "yes" : "no"));
        }
    }
}


Measured memory_bytes: 46512
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, m, i, j, o;
    String[] u;
    String t;

    n = sc.nextInt();
    u = new String[n];
    for(i = 0;i < n;i++)u[i] = sc.next();

    m = sc.nextInt(); o = 0;
    for(i = 0;i < m;i++){
      t = sc.next();
      for(j = 0;j < n;j++)if(u[j].equals(t)){
        if(o % 2 == 0)out.print("Opened by ");
        else out.print("Closed by ");
        out.println(t);
        o++;
        break;
      }
      if(j == n)out.println("Unknown " + t);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int wa(){
	cout << "WA" << endl;
	return 0;
}

int main(){
	string S; cin >> S;
	if(S[0] != 'A') return wa();
	int x = 1;
	while(x < (int)S.size() && S[x] != 'C') ++x;
	if(x == 1 || x >= (int)S.size()-1) return wa();
	repp(i,1,S.size()) if(i != x && 'A' <= S[i] && S[i] <= 'Z') return wa();
	cout << "AC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int dp[10][100010];
signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int a[100010],b[100010],c[100010];
    int dp[10][100010];
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = 0;
    dp[1][0] = 0;
    dp[2][0] = 0;
    for(int i=1;i<=n;i++){
        dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1],dp[1][i-1]);
    }
    cout << max(dp[0][n],max(dp[1][n],dp[2][n])) << "\n";
    return 0;
}


Measured memory_bytes: 4608
N,A,B = map(int, input().split())

ans = []

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)


for i in range(1,N+1):
    Number = digitSum(i)
    if A <= Number <= B:
        ans.append(i)

print(sum(ans))


Measured memory_bytes: 3424
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <stack>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	std::string dir;
	cin >> dir;

	while (dir != "#") {
		std::stack<bool> d;
		int count = 0;
		for (int i = 0; i < dir.length(); i++) {
			if (dir[i] == 'n') {
				d.push(true);
				count++;
			}
			if (dir[i] == 'w') {
				d.push(false);
				count++;
			}
		}

		double a;
		if (d.top()) {
			a = 0;
		}
		else {
			a = 90;
		}
		d.pop();

		int t = 1;
		while (!(d.empty())) {
			if (d.top()) {
				a -= 90/pow(2,t);
			}
			else {
				a += 90/pow(2,t);
			}
			t++;
			d.pop();
		}
		if (count == 1) {
			cout << a << endl;
		}
		else {
			if (count == 2) {
				cout << a << endl;
			}
			else {
				cout << std::setprecision(12) << a * pow(2,count-2) << "/" << pow(2,count-2) << endl;
			}
		}
		cin >> dir;
	}

	return 0;
}

Measured memory_bytes: 3396
N=int(input())
A=list(map(int,input().split()))

def hyouji(A):
    for z in range(len(A)):
        if z==0:
            print(A[z],end="")
        else:
            print(" "+str(A[z]),end="")
    print()

hyouji(A)
for i in range(1,N):
    v=A[i]
    j=i-1

    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
    A[j+1]=v

    hyouji(A)



Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   ll n,f=0,mn=INT_MAX,mx=0;
   string s;
   cin>>s;
   n=s.length();
   map<char,ll>m;
   for(int i=0;i<n;i++)
    {
      m[s[i]]++;
    } 
    if((m.size()==1&&n>1)||(m.size()==2&&n>2))
      f=1;
    if(m.size()==3)
    {
      for(auto t:m)
    {
        mn=min(mn,t.se);
      //cerr<<t.fi<<" "<<t.se<<endl;
    }
          for(auto t:m)
    {
      mx=max(mx,t.se-mn);
      
    }
  
    ///cerr<<mn<<" "<<mx<<endl;
    if(mx>=m.size()-1)
      f=1;}
    if(f)
      NO
    else
      YES
    
    
    
}
return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception{
		
//		BufferedReader br = new BufferedReader(new FileReader(input_file));
//		PrintWriter out = new PrintWriter(output_file);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
//		String[] input = br.readLine().split(" ");
//		int tc = Integer.parseInt(input[0]);
		int tc = 1;
		for(int iter = 1; iter <= tc; iter++) {
			String str = br.readLine();
			int n = str.length();
			
			long ans = (n * 1l * (n - 1)) / 2 + 1;
			long[] cnt = new long[26];
			
			for(int i = 0; i < n; i++)
				cnt[(int)(str.charAt(i) - 'a')]++;
				
			for(int i = 0; i < 26; i++)
				ans -= (cnt[i] * (cnt[i] - 1)) / 2;
			out.println(ans);
		}
		
		out.close();
		
	}
	
	static void debug(Object... o) {
	    System.out.println(Arrays.deepToString(o));
	}
}


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

int main(){
  int D;
  cin >>D;
  string ans;
  if(D==25) ans = "Christmas";
  if(D==24) ans = "Christmas Eve";
  if(D==23) ans = "Christmas Eve Eve";
  if(D==22) ans = "Christmas Eve Eve Eve";
  cout << ans << endl;
}

Measured memory_bytes: 256
from math import gcd

def main():
    K = int(input())
    ans = 0
    for i in range(1,K+1):
        for j in range(1,K+1):
            for k in range(1,K+1):
                ans += gcd(gcd(i,j),k)
    print(ans)


if __name__ == "__main__":
    main()

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

class MainClass
{

    public static void Main(string[] args)
    {
        var Nums = LnStrs();
        Console.WriteLine(Nums[2] + " " + Nums[0] + " " + Nums[1]);
    }


    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b){if (a > b){var r = a % b;if (r == 0) return b; else return Gcd(b, r);}else{ var r = b % a; if (r == 0) return a; else return Gcd(a, r); }}
public static int[] LnInts(){var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);var ins = new int[vs.Length];for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);return ins;}public static int LnInt(){var vs = Console.ReadLine().Trim();return int.Parse(vs);}public static long[] LnLngs(){var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);var ins = new long[vs.Length];for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]);return ins;}public static long LnLng(){var vs = Console.ReadLine().Trim();return long.Parse(vs);}public static string[] LnStrs(){var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);return vs;}public static string LnStr(){var vs = Console.ReadLine().Trim();return vs;}}



Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int a,b;
    scanf("%lld %lld", &a, &b);
    long long int result = 0;
    if(b-a<10){
        result = a;
        FOR(i,a+1,b+1){
            result^=i;
        }
    }else{
        if(a%2){
            result^=a;
            a++;
        }
        if(b%2==0){
            result^=b;
            b--;
        }
        result^=((b-a+1)/2)%2;


    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	n := readi()
	a := atoi(readSlice())
	for i := 0; i < n; i++ {
		if a[i]&1 == 0 && !(a[i]%3 == 0 || a[i]%5 == 0) {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}
func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 640
coin = [500,100,50,10,5,1]
while True:
  N = 1000-int(input())
  if N == 1000:
    break
  i = 0
  ans = 0
  for j in coin:
    ans += N//j
    N = N%j
    if N == 0:
      break
  print(ans)


Measured memory_bytes: 5588
//	Id:lys2002
//	Time:2020/8/7 15:24
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)

typedef double db;
typedef long long ll;

const ll md=1000000007;

inline void Fio(){
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    N%=1000;
    cout<<(1000-N)%1000<<endl;
    return 0;
  }


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mk  make_pair
#define pb  push_back


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<ll> v;
    for(ll i=0;i<n-1;i++){
        ll a;
        cin>>a;
        v.push_back(a);
    }
    ll ar[n+10];
    memset(ar,0,sizeof(ar));
    for(ll i=v.size()-1;i>=0;i--){
        ll x=v[i];
        ar[x]++;
    }
    for(ll i=1;i<=n;i++) cout<<ar[i]<<endl;
    return 0;
}


Measured memory_bytes: 6372
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        var count = 0;
        for (int i = 0; i < s.Length; i++)
            if (s[i] != t[i]) count++;
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 27328
import sys
sys.setrecursionlimit(10**6)

n = int(input())

sp = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    sp.append([s,p, i+1])

sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])

ans = [i[2] for i in sp]

print(*ans)

Measured memory_bytes: 8940
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
vector<int> geko;
int solve(int now) {
	vector<int> newer;
	REP(i, geko.size()) {
		if (geko[i] >= now) {
			if (i == 0 || i == geko.size() - 1) newer.push_back(1);
			newer.push_back(1);
		}
		else {
			if (i == 0 || i == geko.size() - 1) newer.push_back(0);
			newer.push_back(0);
		}
	}
	int itr[2] = { 10000000,100000000};
	int ans[2] = {};
	int mid = newer.size() / 2;
	for (int i = mid-1; i >= 0; --i) {
		if (newer[i] == newer[i + 1]) {
			itr[0] = i;
			ans[0] = newer[i];
			break;
		}
	}
	for (int i = mid+1; i < newer.size(); ++i) {
		if (newer[i] == newer[i - 1]) {
			itr[1] = i;
			ans[1] = newer[i];
			break;
		}
	}
	if (abs((int)newer.size()/2 - itr[0]) > abs((int)newer.size()/2 - itr[1])) {
		return ans[1];
	}
	else {
		return ans[0];
	}
}
int main() {
	int n;
	cin >> n;
	REP(i, 2 * n - 1) {
		int a;
		cin >> a;
		geko.push_back(a);
	}
	int bot = 1;
	int top = 2 * n;
	while (top - bot > 1) {
		int mid = (top + bot) / 2;
		if (solve(mid) == 1) {
			bot = mid;
		}
		else {
			top = mid;
		}
	}
	cout << bot << endl;
}


Measured memory_bytes: 2896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,m,i,j,p,q;
	bool flag;
	string a[55],b[55];
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<m; ++i){
		cin >> b[i];
	}
	for(i=0; i<=(n-m); ++i){
		for(j=0; j<=(n-m); ++j){
			flag = true;
			for(p=0; p<m; ++p){
				for(q=0; q<m; ++q){
					if(a[i+p][j+q] != b[p][q]){
						flag = false;
						break;
					}
				}
				if(!flag){
					break;
				}
			}
			if(flag){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//0xor1xor...xor(2^m-1)=0(m=1除外) 
using namespace std;
int n,m,k;
int main() {
    cin>>m>>k;
    n=pow(2,m);
    if(m==1 && k==1){
        cout<<-1<<endl;
        return 0;
    }
    if(n<=k){
    	cout<<-1<<endl;
    	return 0;
    }
    if(k==0){
    	for(int i=0;i<n;i++)
    		cout<<i<<" "<<i<<" ";
    	cout<<endl;
    	return 0;
    }
    cout<<k<<" ";
    for(int i=0;i<n;i++)
    	if(i!=k)
    		cout<<i<<" ";
    cout<<k<<" ";
    for(int i=n-1;i>=0;i--)
    	if(i!=k)
    		cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    int A[100000], B[100000];
    for(int i=0;i<N;i++)
        cin >> A[i] >> B[i];
    
    ll sum;
    pair<ll , int> C[100000];
    for(int i=0;i<N;i++){
        sum = A[i] + B[i];
        C[i] = make_pair(sum, i);
    }
    // 昇順ソート
    sort(C, C + N);
    int index;
    ll ans = 0;
    for(int i=0;i<N;i++){
        index = C[N-i-1].second;
        ans += A[index];
        i++;
        if(i==N)
            break;
        index = C[N-i-1].second;
        ans -= B[index];
    }

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

Measured memory_bytes: 2560
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
P = list(map(int,input().split()))

ans = 0
for i in range(N-2):
    A = [P[i],P[i+1],P[i+2]]
    A.sort()
    if A[1]==P[i+1]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void){
    int i, j, N, ans=1;
    scanf("%d", &N);
    char **W, last;
    if((W=malloc(sizeof(char *)*N)) == NULL) exit(1);
    for(i=0; i<N; i++){
        if((W[i]=malloc(sizeof(char)*15)) == NULL) exit(1);
    }

    scanf("%s", W[0]);
    for(i=1; i<N; i++){
        scanf("%s", W[i]);
        for(j=i-1; j>=0; j--){
            if(strcmp(W[i], W[j]) == 0) ans=0;
        }
        for(j=0; W[i-1][j]!='\0'; j++) last = W[i-1][j];
        if(last != W[i][0]) ans=0;
    }
    (ans == 1)? printf("Yes\n"): printf("No\n");
    for(i=0; i<N; i++) free((void *)W[i]);
    free((void *)W);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    string s1,s2;
    cin >> s1 >> s2;
    cout << 'A' << s2.at(0) << 'C' << endl;

}

Measured memory_bytes: 256
from collections import deque

N = int(input())
v = list(map(int,input().split()))

v.sort()

deq = deque(v)

while len(deq) != 1:
    x = deq.popleft()
    y = deq.popleft()
    
    nx = (x+y)/2
    
    deq.appendleft(nx)

ans = deq.popleft()

print(ans)

Measured memory_bytes: 65004
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String s = sc.next();
		String msg = "yes";

		for (int i = 0; i < s.length(); i++) {
			for (int j = i + 1; j < s.length(); j++) {
				if (s.charAt(i) == s.charAt(j)) {
					msg = "no";
				}
			}
		}

		System.out.println(msg);

	}
}

Measured memory_bytes: 22100
#include <stdio.h>

int debt_amount(int, int);

int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", debt_amount(100000, n));
	return 0;
}

int debt_amount(int a, int x){
	if(x >= 1){
		a = (a + a*0.05)/1000 + 0.999;
		a = a*1000;
		return debt_amount(a, x-1);
	}else{
		return a;
	}
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt(),c = scanner.nextInt();
		if(a+b == c || a+c == b || b+c == a){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22868
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    d,t,s = map(int,ipt().split())
    if d > t*s:
        print("No")
    else:
        print("Yes")

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 68748
def F(a,b):
  m = max(a,b)
  count=1
  while m//10!=0:
    count+=1
    m//=10
  return count

N = int(input())
tmp=F(1,N)
for i in range(round(N**0.5),1,-1):
  if N%i==0:
    if tmp>F(i,N//i):
      tmp = F(i,N//i)
      break
print(tmp)
  

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << (b%a?b-a:a+b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
        cout << "YES"
             << "\n";
    else
        cout << "NO"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
n=input()
N=int(n)
if 1<=N and N<1000:
  ch1=1000-N
  print(ch1)
else:
  if int(n[3])==0 and int(n[2])==0 and int(n[1])==0 :
    print(0)
  else:
    ch2=1000*(int(n[0])+1)-N
    print(ch2)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
typedef struct {
    int a; int b;
}Sord;
bool cmp(const Sord& x, const Sord& y) {
    if(x.a != y.a) return x.a < y.a;
    else {
        return x.b > y.b;
    }
}
int main() {
    int n, h; cin >> n >> h;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    int ma = a[0];
    int ans = 0;
    for(auto it : b) {
        if(h <= 0) break;
        if(it > ma) {
            ans++;
            h -= it;
        }else break;
    }
    if(h > 0) ans += (h+ma-1)/ma;
    cout << ans;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    string ans = "";
    while(abs(n) > 0){
        ans = to_string(abs(n % 2)) + ans;
        n -= abs(n % 2);
        n /= -2;
    }

    if(ans == "") cout << "0" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if (s < t) yes;
    else no;
    return 0;
}


Measured memory_bytes: 256