akhauriyash/Code-Regression huggingface dataset:
import sys


class UnionFind(object):
    def __init__(self, N):
        self._parent = list(range(N))
        self.__num_component = [1] * N

    def root(self, x):
        if self._parent[x] == x:
            return x
        else:
            # root abbreviation
            self._parent[x] = self.root(self._parent[x])
            return self._parent[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def num_connected(self, x):
        return self.__num_component[self.root(x)]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if (x == y):
            return
        rank_x = self.__num_component[x]
        rank_y = self.__num_component[y]
        if rank_x < rank_y:
            self._parent[x] = y
            self.__num_component[y] += rank_x
        else:
            self._parent[y] = x
            # if rank_x == rank_y:
            #     self._rank[x] += 1
            self.__num_component[x] += rank_y
        return


fin = sys.stdin.readline
N, M = [int(elem) for elem in fin().split()]
bridges = tuple(
    tuple(int(elem) - 1 for elem in fin().split())
    for _ in range(M)
)

uf = UnionFind(N)
num_incovenient_list = [N * (N - 1) // 2]
for A, B in bridges[::-1]:
    num_islands_A = uf.num_connected(A)
    num_islands_B = uf.num_connected(B)
    if not uf.same(A, B):
        num_incovenient_list.append(
            num_incovenient_list[-1] - num_islands_A * num_islands_B)
        uf.unite(A, B)
    else:
        num_incovenient_list.append(num_incovenient_list[-1])

num_incovenient_list.pop()

for num_incovenient in num_incovenient_list[::-1]:
    print(num_incovenient)


Measured memory_bytes: 111708
#include<bits/stdc++.h>
#define pii pair<int,int>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
const int P=1000000007;
const int N=210000;
pii a[N];int n;
int main(){
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d",&a[i].first);a[i].second=-1;
    }
    rep(i,1,n){
        scanf("%d",&a[i+n].first);a[i+n].second=1;
    }
    sort(a+1,a+1+2*n);
    int ans=1;
    int pre=0;
    rep(i,1,2*n){
        if(pre==0){
            pre+=a[i].second;
        }
        else{
            if(a[i].second*pre>0)pre+=a[i].second;
            else{
                ans=ans*1ll*abs(pre)%P;
                pre+=a[i].second;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}



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

int main()
{
    int n1, n2, n3, mayor, suma, auxiliar,maximo,aux2;
    cin>>n1 >> n2>> n3;

    if ( n3>=n2 && n3>=n1 ){
        mayor=n3;
        auxiliar=n1+n2;
        aux2=mayor-1;
        if(auxiliar>=aux2){
            maximo=n3+n2;
        }
        else{
             maximo=auxiliar+1+n2;
        } 
    }
    else{
        maximo=n3+n2;
    }
    
    cout<<maximo;

}

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

int main(void) {
    int n;
    cin >> n;
    vector<long> h(n);
    for(auto &x: h) cin >> x;

    long mx = -1;
    long res = 0;
    for(auto &x: h)
        if(mx <= x)
            mx = x, res++;
    cout << res << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
struct mat{
    LL a[55][55];
    int n;
    mat(){
        MEM(a);
    }
};
int mod=1e9+7;
void print(const mat &a){
    int n=a.n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            printf("%lld ",a.a[i][j]);
        }
        printf("\n");
    }
    printf("\n");
}
mat operator*(const mat &a,const mat &b){
    mat c;
    int n=a.n;
    c.n=n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                c.a[i][j]+=a.a[i][k]*b.a[k][j];
                c.a[i][j]%=mod;
            }
        }
    }
    /*print(a);
    print(b);
    print(c);
    printf("ok\n");
    int xxx;
    scanf("%d",&xxx);*/
    return c;
}
mat f_pow(mat a,LL k){
    mat res,temp=a;
    res.n=temp.n;
    for(int i=0;i<res.n;i++)
    res.a[i][i]=1;
    while(k){
        if(k&1)res=res*temp;
        temp=temp*temp;
        k>>=1;
    }
    return res;
}
int main(){
    LL n,k;
    scanf("%lld %lld",&n,&k);
    mat temp;
    temp.n=n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%lld",&temp.a[i][j]);
        }
    }
    mat res=f_pow(temp,k);
    LL ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          //  printf("%d ",res.a[i][j]);
            ans+=res.a[i][j];
        }
      //  printf("\n");
    }
    printf("%lld\n",ans%mod);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> mx(n, 0);
  rep(i, n) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    mx[a] = max(mx[a], h[b]);
    mx[b] = max(mx[b], h[a]);
  }
  int ans = 0;
  rep(i, n) {
    if (h[i] > mx[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("e.in", "r", stdin);
        freopen("e.out", "w", stdout);
    #endif
}

ll x, y, a, b, c, p[N], q[N], r[N], prp[N], prq[N], ans;
vector <pll> vec;

int main() {
	data();
	scanf("%lld %lld %lld %lld %lld", &x, &y, &a, &b, &c);
	for (int i = 1; i <= a; ++i) {
		scanf("%lld", &p[i]);	
		vec.pb(mp(p[i], 1));
	}
	for (int i = 1; i <= b; ++i) {
		scanf("%lld", &q[i]);
		vec.pb(mp(q[i], 2));
	}
	for (int i = 1; i <= c; ++i) {
		scanf("%lld", &r[i]);
		vec.pb(mp(r[i], 3));
	}
	sort(all(vec));
	sort(p + 1, p + a + 1);
	sort(q + 1, q + b + 1);
	sort(r + 1, r + c + 1);
	for (int i = 1; i <= a; ++i)
		prp[i] = prp[i - 1] + p[i];
	for (int i = 1; i <= b; ++i)
		prq[i] = prq[i - 1] + q[i];
	reverse(all(vec));
	ans = prp[a] - prp[a - x] + prq[b] - prq[b - y];
	for (int i = c; i >= 1; --i) {
		if (!x && !y)
			break;
		if (x && y && r[i] > p[a - x + 1] && r[i] > q[b - y + 1]) {
			if (p[a - x + 1] > q[b - y + 1]) {
				ans -= q[b - y + 1];
				y--;
				ans += r[i];
			}				
			else {
				ans -= p[a - x + 1];
				x--;
				ans += r[i];
			}
					
		}
		else if (x && r[i] > p[a - x + 1]) {
			ans -= p[a - x + 1];
			x--;
			ans += r[i];
		}
		else if (y && r[i] > q[b - y + 1]) {
			ans -= q[b - y + 1];
			y--;
			ans += r[i];			
		}
	}
	printf("%lld", ans);
}
 
/*
	Timus: 288481RF
	CodeForces: fractal
*/

Measured memory_bytes: 15468
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using UMII = unordered_map <int, int> ;

vector <int> getRange(vector<int>& pnts, UMII& lCnt, UMII& confirmedCnt, int upperBound) {
    const int UPPER = 1000000001;
    int startVal = UPPER;
    int endVal = 0;

    int lcnt = 0;
    int confirmed = 0;

    for (int i = 0; i < pnts.size(); ++i) {
        if (i && pnts[i] == pnts[i-1]) {
            continue;
        }

        lcnt += lCnt[pnts[i]];

        if (lcnt >= upperBound && confirmed < upperBound) {
            startVal = min(startVal, pnts[i]);
            endVal = max(endVal, pnts[i]);
        }

        confirmed += confirmedCnt[pnts[i]];
    }

    return {startVal, endVal};
}

int main() {
    int N;
    cin >> N;
    vector < int > pnts;

    int factor = N%2 == 0 ? 2 : 1;
    UMII lCnt;
    UMII confirmedCnt;

    for (int i = 0; i < N; ++i) {
        int A;
        int B;
        cin >> A >> B;

        pnts.push_back(A);
        pnts.push_back(B);

        ++lCnt[A];
        ++confirmedCnt[B];
    }

    int startVal = 1000000001;
    int endVal = 0;
    int upperBound = (N+1)/2;

    sort(pnts.begin(), pnts.end());
    vector <int> res = getRange(pnts, lCnt, confirmedCnt, upperBound);

    if (N%2 == 0) {
        vector <int> res2 = getRange(pnts, lCnt, confirmedCnt, upperBound+1);
        cout << res[1]+res2[1] - res[0] - res2[0] + 1 << endl;
    } else {
        cout << res[1] - res[0] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 37860
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

ll n;
ll h[112];

int main() {
	
	while (cin >> n, n) {
		REP(i, n + 1) scanf("%lld", h + i);
		
		ll A, D;
		REP(i, 5) {
			vector<ll> v;
			REP(j, 5) if (i != j) v.push_back(h[j]);
			if (v[1] - v[0] == v[2] - v[1] && v[2] - v[1] == v[3] - v[2]) D = v[1] - v[0];
		}
		
		REP(i, 5) {
			vector<ll> v;
			REP(j, 5) if (i != j) v.push_back(h[j]);
			if (v[0] + D == v[1] && v[0] + 2 * D == v[2] && v[0] + 3 * D == v[3]) A = v[0];
		}
		
		ll SUM = (ll)n * (A + A + D * (n - 1)) / 2;
		ll sum = 0;
		REP(i, n + 1) sum += h[i];
		
		cout << sum - SUM << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3132
#include<iostream>
using namespace std;
typedef long long ll;
#define NODE_MAX 10001
int par[NODE_MAX],rk[NODE_MAX];
void init(){
  for(int i=0;i<NODE_MAX;i++){
    par[i]=i;
    rk[i]=0;
  }
}
int root(int x){
  if(x==par[x]) return x;
  return par[x]=root(par[x]);
}
void unite(int x,int y){
  x = root(x);
  y = root(y);
  if(x==y) return;

  if(rk[x]<rk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rk[x]==rk[y]) rk[x]++;
  }
}
bool same(int x,int y){
  return root(x)==root(y);
}
int main(){
  init();
  ll n ,m,com,x,y;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> com >> x >> y;
    if(com==0){
      unite(x,y);
    }else if(com==1){
      if(same(x,y)){
        cout << "1\n";
      }else{
        cout << "0\n";
      }
    }
  }
}



Measured memory_bytes: 3144
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

const int MAXN = 1e5 + 5;

vector < vector < pair < ll, ll > > > adj(MAXN, vector < pair < ll, ll > > ());

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

  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int u, v, wt;
    cin >> u >> v >> wt;
    adj[u].push_back({v, wt});
    adj[v].push_back({u, wt});
  }

  for(int i = 1; i < n; i++){
    adj[i + 1].push_back({i, 0});
  }
  priority_queue < pair < ll, int > , vector < pair < ll, ll > >, greater < pair < ll, ll > > > q;
  vector < ll > d(n + 1, 1e17);
  vector < bool > used(n + 1, false);
  used[1] = true;
  d[1] = 0;
  q.push({d[1], 1});
  while(!q.empty()){
    int u = q.top().second;
    ll d_u = q.top().first;
    q.pop();
    if(d_u != d[u]) continue;
    for(auto edge : adj[u]){
      int to = edge.first;
      int len = edge.second;
      if(!used[to] && d[u] + len < d[to]){
        d[to] = d[u] + len;
        q.push({d[to], to});
      }
    }
  }

  if(d[n] == 1e17) cout << -1 << '\n';
  else cout << d[n] << '\n';
}


Measured memory_bytes: 12792
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,N,ansPre[2019]={0},ans[2019]={0},res=0;
	string S;
	cin>>S;
	N=S.length();
	for(int i=0;i<N;i++){
		n=S[i]-'0';
		fill(ans,ans+2019,0);
		ans[n]+=1;
		for(int j=0;j<=2018;j++)ans[(j*10+n)%2019]+=ansPre[j];
		for(int j=0;j<=2018;j++)ansPre[j]=ans[j];
		res+=ans[0];
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N,X;
cin>>N>>X;
int pos=0;
int ans=1;
int L;
for(int i=0;i<N;++i){
  cin>>L;
  pos+=L;
  if(pos<=X){
    ans+=1;
  }
}
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] s = br.readLine().toCharArray();
		int q = Integer.parseInt(br.readLine());

		BIT[] arr = new BIT[26];
		for (int i = 0; i < 26; i++) {
			arr[i] = new BIT(500000);
		}
		for (int i = 0; i < n; i++) {
			arr[s[i] - 'a'].add(i + 1, 1);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			String[] sa = br.readLine().split(" ");
			if (sa[0].equals("1")) {
				int idx = Integer.parseInt(sa[1]) - 1;
				int bef = s[idx] - 'a';
				arr[bef].add(idx + 1, -1);

				char ch = sa[2].charAt(0);
				int aft = ch - 'a';
				arr[aft].add(idx + 1, 1);
				s[idx] = ch;
			} else {
				int l = Integer.parseInt(sa[1]) - 1;
				int r = Integer.parseInt(sa[2]);
				int ans = 0;
				for (int j = 0; j < 26; j++) {
					if (arr[j].sum(r) - arr[j].sum(l) > 0) {
						ans++;
					}
				}
				pw.println(ans);
			}
		}
		pw.flush();
		br.close();
	}

	static class BIT {
		int n;
		long[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new long[n + 1];
		}

		void add(int idx, long val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		long sum(int idx) {
			long sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}
}


Measured memory_bytes: 156296
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  ll X,K,D;
  cin >> X >> K >> D;

  ll fac=abs(X)/D;

  ll ans=100000000000;
  if(K<=fac) ans=abs(X)-K*D;
  else{
    ll K_nokori=K-fac;
    if(K_nokori%2==0) ans=abs(X)-fac*D;
    else ans=abs(abs(X)-fac*D-D);
  }

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


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;


int N, M;
ll A[200005];
int nx[200005] = {};
ll dp[200005];
int main() {
	cin >> N >> M;
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, M) {
		int l, r;
		cin >> l >> r; l--;
		nx[l] = max(nx[l], r);
	}

	rep(i, N) {
		nx[i] = max(nx[i], i + 1);
		nx[i + 1] = max(nx[i + 1], nx[i]);
	}


	rep(i, N) {
		dp[i + 1] = max(dp[i + 1], dp[i]);
		dp[nx[i]] = max(dp[nx[i]], dp[i] + A[i]);
	}

	cout << dp[N] << endl;


	return 0;
}


Measured memory_bytes: 6916
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, M;
int A[100000], B[100000];
vector<int> E[100000];
int dist[100000];

signed main(){
    cin >> N >> M;
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        E[A[i]].pb(B[i]);
        E[B[i]].pb(A[i]);
    }

    rep(i, N) dist[i] = INT_MAX;
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int n = que.front();
        que.pop();
        rep(i, E[n].size()){
            if(dist[E[n][i]] > dist[n] + 1){
                dist[E[n][i]] = dist[n] + 1;
                que.push(E[n][i]);
            }
        }
    }

    rep(i, M){
        if(dist[A[i]]%2 == dist[B[i]]%2){
            cout << (ll)N*(N-1)/2 - M << endl;
            return 0;
        }
    }
    ll cnt = 0;
    rep(i, N){
        cnt += dist[i]%2;
    }
    cout << cnt*(N-cnt) - M << endl;
}

Measured memory_bytes: 10376
#include <iostream>
#include <algorithm>
using namespace std;
static const int LEFT = -1000000;
static const int RIGHT = 1000000;
int main() {
    int K, X;
    cin >> K >> X;
    for (int i = max(LEFT, X - K + 1); i <= min(RIGHT, X + K - 1); i++)
        cout << i << " ";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define MAX 1001

void initialize(char array[], int n);
void judge(char input[], char target[]);

main()
{
	char input[MAX];
	char target[7] = {'H','o','s','h','i','n','o'};
	initialize(input, MAX);
	int i = 0, n = 0;
	scanf("%d\n", &n);
	for(i = 0; i < n; i++)
	{
		gets(input);
		judge(input, target);
		printf("%s\n", input);
		initialize(input, MAX);
	}
	return 0;
}
void initialize(char array[], int n)
{
	short i = 0;
	for(i = 0; i < MAX; i++)
	{
		array[i] = 0x00;
	}
}
void judge(char input[], char target[])
{
	short i = 0, j = 0;
	for(i = 0; input[i] != 0x00; i++)
	{
		if(input[i] == target[0])
		{
			for(j = 0; j < 7; j++)
			{
				if((j < 5) && (input[i + j] != target[j]))
				{
					break;
				}
				else if((j == 6) && (input[i + j] == 'o'))
				{
					input[i + j] = 'a';
				}
			}
		}
	}
}

Measured memory_bytes: 580
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = input()
A = inputIL()

print(1/sum(1/x for x in A))

Measured memory_bytes: 64492
from bisect import bisect
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
def d(x, y, z): return abs(x - y) + abs(y - z)
for x in X:
    ans = float("inf")
    i = bisect(S, x)
    if i < A:
        j = bisect(T, S[i])
        if j < B:
            ans = min(ans, d(x, S[i], T[j]))
        if j > 0:
            ans = min(ans, d(x, S[i], T[j-1]))
    if i > 0:
        j = bisect(T, S[i-1])
        if j < B:
            ans = min(ans, d(x, S[i-1], T[j]))
        if j > 0:
            ans = min(ans, d(x, S[i-1], T[j-1]))
    j = bisect(T, x)
    if j < B:
        i = bisect(S, T[j])
        if i < A:
            ans = min(ans, d(x, T[j], S[i]))
        if i > 0:
            ans = min(ans, d(x, T[j], S[i-1]))
    if j > 0:
        i = bisect(S, T[j-1])
        if i < A:
            ans = min(ans, d(x, T[j-1], S[i]))
        if i > 0:
            ans = min(ans, d(x, T[j-1], S[i-1]))
    print(ans)

Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define GOLD ((1 + sqrt(5)) / 2)
const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps(char *x, char *y)
{
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swapi(int *a, int *b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

void preprocess()
{
} //end prepreprocess

void refresh()
{
} //end refresh

void compute()
{
    long long x, i, amount = 100;
    cin >> x;
    for (i = 0; x - amount > 0; ++i)
    {
        amount += (amount / 100);
    }
    cout << i;
} //end compute

int main()
{
#ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("log.txt", "w", stderr);
#endif
    compute();
#ifdef debug
    fprintf(stdout, "\nTIME: %.3lf sec\n", (double)clock() / (CLOCKS_PER_SEC));
#endif
    return 0;
} //end main*

Measured memory_bytes: 3620
#include<cstdio>
using namespace std;

const int length = 4;

int main(){
  char code[10];

  scanf("%s", code);

  char s = code[0];
  bool ans = true;
  for(int i = 1; i < length; i++){
    if (s == code[i]) ans = false;
    s  = code[i];
  }

  if (ans == true){
    printf("Good\n");
  }
  else{
    printf("Bad\n");
  }

  return 0;
}

Measured memory_bytes: 128
<?php
  list($x, $y) = explode(" ", trim(fgets(STDIN)));

  $a[1]=1;
  $a[2]=3;
  $a[3]=1;
  $a[4]=2;
  $a[5]=1;
  $a[6]=2;
  $a[7]=1;
  $a[8]=1;
  $a[9]=2;
  $a[10]=1;
  $a[11]=2;
  $a[12]=1;

  if($a[$x]==$a[$y]) echo "Yes";
  else echo "No";

Measured memory_bytes: 16128
#include<iostream>
using namespace std;
int main() {
	int human, time;
	cin >> human >> time;
	++human;
	int sum = 0;
	int a;
	for (int i = 0; i < time; ++i) {
		cin >> a;
		sum += a;
	}
	cout << sum / human + (sum%human != 0 ? 1 : 0) << endl;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int x, y;

	cin >> x >> y;

	cout << x + (y / 2) << endl;
	
	return 0;
}


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


void solve(){
    int l[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;

    cout << l[K-1];
}

int main(){
    solve();
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        a: [isize;n],
    }

    let mut map = BTreeMap::new();
    let mut count = 0;
    for i in 0..n {
        if let Some(v) = map.get(&(i as isize - a[i])) {
            count += v;
        }
        *map.entry(a[i] + i as isize).or_insert(0usize) += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 11744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
const int inf = 1000000000;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338; // double PI = 4*atan(1);

	 

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	int N,M,C;
    cin >> N >> M >> C;
    vector<int>B(M);
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int res = 0;
        for(int j = 0; j < M; j++) {
            int A;
            cin >> A;
            res += A*B[j];
        }
        res += C;
        if(res > 0) {
            ans++;
        }
    }
    cout << ans << endl;
 }




Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int c[15], a[15][15], n, m, x;
int main() {
    scanf("%d%d%d", &n, &m, &x);
    for(int i = 0; i < n; i++) {
        scanf("%d", &c[i]);
        for(int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int ans = 1e9;
    for(int s = 1; s < 1 << n; s++) {
        vector<int> t(m, 0);
        int sum = 0;
        for(int i = 0; i < n; i++) {
            if((1 << i) & s) {
                sum += c[i];
                for(int j = 0; j < m; j++) {
                    t[j] += a[i][j];
                }
            }
        }
        bool flag = true;
        for(int i = 0; i < m; i++) {
            if(t[i] < x) flag = false;
        }
        if(flag) ans = min(ans, sum);
    }
    if(ans == 1e9) ans = -1;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3764
from collections import deque
"""
https://tjkendev.github.io/procon-library/python/graph/bfs.html
"""
def bfs(G):
    dist = [-1]*(N+M)
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    
    return dist

N,M = map(int,input().split())

graph = [[] for _ in range(N+M)]

for i in range(N):
    KL = list(map(int,input().split()))
    for j in KL[1:]:
        graph[i].append(N+j-1)
        graph[N+j-1].append(i)

ans = bfs(graph)

if -1 in ans[:N]:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 38032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();

		if (x > t) {
			System.out.print(x - t);

		} else {
			System.out.print("0");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int w,h;

    cin>>h>>w;

    int a,b;
    cin>>a>>b;

    int masu[1000][1000];

    rep(i,1000){
        rep(j,1000)masu[i][j]=0;
    }

    for(int i=a;i<w;i++){
        for(int j=0;j<b;j++){masu[j][i]=1;}
    }

    for(int i=b;i<h;i++){
        for(int j=0;j<a;j++){masu[i][j]=1;}

    }
    rep(i,h){
        rep(j,w){
            cout<<masu[i][j];
        }
        cout<<endl;
    }


    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(e, x) for (auto &e : x)
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int N = 1 << 18, inf = 1e9;
char dir[N];
int x[N], y[N];

#define f first
#define s second

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

	int n; cin >> n;

	map<int, vector<pair<int, char>>> RU, DL, UL, RD, RL, UD;
	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> dir[i];
		x[i] *= 10;
		y[i] *= 10;
		if (dir[i] == 'R' || dir[i] == 'U') RU[x[i] + y[i]].eb(x[i], dir[i]);
		if (dir[i] == 'D' || dir[i] == 'L') DL[x[i] + y[i]].eb(x[i], dir[i]);
		if (dir[i] == 'U' || dir[i] == 'L') UL[x[i] - y[i]].eb(x[i], dir[i]);
		if (dir[i] == 'R' || dir[i] == 'D') RD[x[i] - y[i]].eb(x[i], dir[i]);
		if (dir[i] == 'L' || dir[i] == 'R') RL[y[i]].eb(x[i], dir[i]);
		if (dir[i] == 'U' || dir[i] == 'D') UD[x[i]].eb(y[i], dir[i]);
	}

	int ans = inf + 1;
	trav(z, RU) {
		auto &v = z.s;
		sort(all(v));
		rep(i, 0, sz(v) - 1)
			if (v[i].s == 'R' && v[i + 1].s == 'U')
				ckmin(ans, v[i + 1].f - v[i].f);
	}

	trav(z, DL) {
		auto &v = z.s;
		sort(all(v));
		rep(i, 0, sz(v) - 1)
			if (v[i].s == 'D' && v[i + 1].s == 'L')
				ckmin(ans, v[i + 1].f - v[i].f);
	}
	
	trav(z, UL) {
		auto &v = z.s;
		sort(all(v));
		rep(i, 0, sz(v) - 1)
			if (v[i].s == 'U' && v[i + 1].s == 'L')
				ckmin(ans, v[i + 1].f - v[i].f);
	}
	
	trav(z, RD) {
		auto &v = z.s;
		sort(all(v));
		rep(i, 0, sz(v) - 1)
			if (v[i].s == 'R' && v[i + 1].s == 'D')
				ckmin(ans, v[i + 1].f - v[i].f);
	}

	trav(z, RL) {
		auto &v = z.s;
		sort(all(v));
		rep(i, 0, sz(v) - 1)
			if (v[i].s == 'R' && v[i + 1].s == 'L')
				ckmin(ans, (v[i + 1].f - v[i].f) / 2);
	}

	trav(z, UD) {
		auto &v = z.s;
		sort(all(v));
		rep(i, 0, sz(v) - 1)
			if (v[i].s == 'U' && v[i + 1].s == 'D')
				ckmin(ans, (v[i + 1].f - v[i].f) / 2);
	}
	
	if (ans > inf) cout << "SAFE";
	else cout << ans;
}

Measured memory_bytes: 70188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[30];
P info[][5] = {
	P(1, 24), P(4, 27), P(7, 30), P(10, 21), P(16, 18),
	P(1, 28), P(2, 29), P(3, 30), P(15, 16), P(19, 21),
	P(3, 22), P(6, 25), P(9, 28), P(12, 19), P(13, 15),
	P(7, 22), P(8, 23), P(9, 24), P(13, 18), P(10, 12)
};
void rotate(int f){
	rep(i,5)swap(a[info[f][i].fi-1], a[info[f][i].se-1]);
}

bool ok(){
	bool f = true;
	repi(i,2,10)if(a[i-1] != a[i-2])f = false;
	repi(i,11,13)if(a[i-1] != a[i-2])f = false;
	repi(i,14,16)if(a[i-1] != a[i-2])f = false;
	repi(i,20,22)if(a[i-1] != a[i-2])f = false;
	repi(i,17,19)if(a[i-1] != a[i-2])f = false;
	repi(i,23,31)if(a[i-1] != a[i-2])f = false;
	return f;
}

int solve(int cnt){
	if(ok() or cnt == 8)return cnt;
	int ans = INF;
	rep(i,4){
		rotate(i);
		chmin(ans, solve(cnt+1));
		rotate(i);
	}
	return ans;
}

signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n){
		rep(j,30)scanf("%lld", &a[j]);
		//printf("%lld\n", (int)ok());
		int ans = solve(0);
		printf("%lld\n", ans);
	}
	return 0;
}








Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int abso(int n){
    if(n<0) return n*-1;
    return n;
}

int main(){
    int nx,ny,X,Y,W,H,N,latte=0;
    cin>>W>>H>>N;
    for(int i=0;i<N;i++){
        if(i==0){
            cin>>nx>>ny;
            continue;
        }
        else{
            cin>>X>>Y;
            if((X-nx)*(Y-ny)>0){
                latte+=max(abso(X-nx),abso(Y-ny));
            }
            else{
                latte+=abso(X-nx)+abso(Y-ny);
            }
            nx=X;ny=Y;
        }
        //printf("%d\n",latte);
    }
    printf("%d\n",latte);
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*power((a*a)%mod,n/2))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int md = 998244353;
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
int n;
vector<int>a(maxn),x(maxn);

signed main()
{
    showoff;
    cin >> n;
    FOR(i,1,n+1)cin >> a[i];
    int tot = 2*a[2];
    FOR(i,3,n+1){
        if(i%2)tot -= 2*a[i];
        else tot += 2*a[i];
    }
    x[2] = (2*a[1]+tot)/2;
    x[1] = 2*a[1]-x[2];
    FOR(i,2,n)x[i+1] = 2*a[i]-x[i];
    FOR(i,1,n+1)cout << x[i] <<  " ";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...  

Measured memory_bytes: 4480
#include<iostream>
typedef long long LL;
LL a[100005];
LL b[100005];
int main(void)
{
	int n;
	LL k = 0;
	scanf("%d", &n);
	for (int i = 0; i < n + 1; i++)
	{
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &b[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (b[i] >= a[i])
		{
			k += a[i];
			b[i] -= a[i];
			if (b[i] >= a[i + 1])
			{
				k += a[i + 1];
				a[i + 1] = 0;
			}
			else
			{
				k += b[i];
				a[i + 1] -= b[i];
			}
		}
		else
		{
			k += b[i];
		}
	}
	printf("%lld\n", k);

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  queue<string> q1;
  queue<int> q2;
  for(int i=0; i<n; i++) {
   string name;
   int time;
   cin >> name >> time;
   q1.push(name);
   q2.push(time);
  }
  int time = 0;
  while (!q1.empty()) {
   string s = q1.front();
   int n = q2.front() - q;
   if (n <= 0) {
    q1.pop();
	q2.pop();
	time += n + q;
	cout << s << " " << time << endl;
   }
   else {
    q1.pop();
	q2.pop();
	q1.push(s);
	q2.push(n);
	time += q;
   }
  }
}


Measured memory_bytes: 4164
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;
import std.typecons;
import std.format;

int[Tuple!(long, long, long)] patterns;
long answer;

void solve(long a, long b, long c, long x)
{
	auto key = tuple(a, b, c);
	if (key in patterns) {
		return;
	}
	patterns[key] = 0;

	if (x == 0) {
		answer++;
	}
	else if (x < 0) {
		return;
	}

	if (a > 0) {
		solve(a-1, b, c, x-500);
	}
	if (b > 0) {
		solve(a, b-1, c, x-100);
	}
	if (c > 0) {
		solve(a, b, c-1, x-50);
	}
}

void main(string[] argv)
{
	long a = readln.chomp.to!long;
	long b = readln.chomp.to!long;
	long c = readln.chomp.to!long;
	long x = readln.chomp.to!long;

	answer = 0;
	solve(a, b, c, x);
	writeln(answer);
}


Measured memory_bytes: 8060
#sort ??§??????????????????????????????
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True) :
   del phU[-2]
   try :
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 del phL[0]
 del phL[-1]
 ph = phU + phL
 return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

Measured memory_bytes: 33272
import sys

def input_number():
    for i in range(n):
        adding=map(int,raw_input().split())
        A.append(adding)
    for i in range(m):
        adding=map(int,raw_input().split())
        B.append(adding)

if __name__ == '__main__':
    n,m,l=map(int,raw_input().split())
    A=[]
    B=[]
    ans=[[0 for j in range(l)]for i in range(n)]
    input_number()
    for i in range(n):
        for j in range(l):
            for k in range(m):
                ans[i][j] += A[i][k] * B[k][j]
    for i in range(n):
        for j in range(l):
            sys.stdout.write("%d" % ans[i][j])
            if j != l-1:
                sys.stdout.write(" ")
        sys.stdout.write("\n")

Measured memory_bytes: 7208
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int v[1010]={0};
int w[1010]={0};
int dp[1010][10010]={{0}};
int n,W;
int main(){
    cin>>n>>W;
    for(int i =0;i <n;i++){
        cin>>v[i]>>w[i];
    }
    for(int i =0;i < n;i++){
        for(int j =0;j <=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout <<dp[n][W]<<endl;
    return 0;
}

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

int main() {
  int N,A,B,x;
  cin >>N>>A>>B;
  if (A*N>=B){
    x=B;
    cout << x <<endl;
  }
  else {
    x=A*N;
      cout << x << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
   public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            graph.add(new ArrayList<>());
        }
        int[] prices = new int[n + 1];
        int[] times = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            prices[i] = sc.nextInt();
            times[i] = sc.nextInt();
        }
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            graph.get(a).add(b);
            graph.get(b).add(a);
        }
        int[][] costs = new int[n][n + 1];
        for (int i = 0; i < n; i++) {
            Arrays.fill(costs[i], Integer.MAX_VALUE);
        }
        PriorityQueue<Path> queue = new PriorityQueue<>();
        queue.add(new Path(1, 1, 0));
        while (queue.size() > 0) {
            Path p = queue.poll();
            p.time--;
            if (costs[p.time][p.idx] <= p.value) {
                continue;
            }
            costs[p.time][p.idx] = p.value;
            for (int x : graph.get(p.idx)) {
                int nextCost = p.value + prices[p.idx];
                int nextTime = times[p.idx];
                if (nextTime > p.time && costs[nextTime - 1][x] > nextCost) {
                    queue.add(new Path(x, nextTime, nextCost));
                }
                if (p.time > 0 && costs[p.time - 1][x] > p.value) {
                    queue.add(new Path(x, p.time, p.value));
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            min = Math.min(min, costs[i][n]);
        }
        System.out.println(min);
    }
    
    static class Path implements Comparable<Path> {
        int idx;
        int time;
        int value;
        
        public Path(int idx, int time, int value) {
            this.idx = idx;
            this.time = time;
            this.value = value;
        }
        
        public int compareTo(Path another) {
            return value - another.value;
        }
        
        public String toString() {
            return idx + ":" + time + ":" + value;
        }
    }
}


Measured memory_bytes: 210252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    static private node t = null;
    final static private StringBuilder sb = new StringBuilder();
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        String in;
        for(int i = 0; i<n; i++){
            in = br.readLine();
            if(in.charAt(0)=='p'){
                inorder(t);
                sb.append('\n');
                preorder(t);
                sb.append('\n');
            }else if(in.charAt(0)=='i'){
                insert(new node(Integer.parseInt(in.substring(7))));
            }else if(in.charAt(0)=='f'){
                sb.append(find(Integer.parseInt(in.substring(5))) ? "yes\n" : "no\n");
            }else{
                delete(Integer.parseInt(in.substring(7)));
            }
        }
        System.out.print(sb);
    }
    static void insert(node z){
        node y = null;
        node x = t;
        while(x!=null){
            y = x;
            if(z.key<x.key){
                x = x.left;
            }else{
                x = x.right;
            }
        }
        if(y==null){
            t = z;
        }else if(z.key<y.key){
            y.left = z;
        }else{
            y.right = z;
        }
    }
    static boolean find(int key){
        node x;
        for(x = t; x!=null&&x.key!=key; x = key<x.key ? x.left : x.right);
        return x!=null&&x.key==key;
    }
    static void delete(int key){
        node y = null;
        node x;
        for(x = t; x!=null&&x.key!=key; y = x, x = key<x.key ? x.left : x.right);
        if(x==null||x.key!=key) return;
        if(x.left==null){
            if(key<y.key) y.left = x.right;
            else y.right = x.right;
        }else if(x.right==null){
            if(key<y.key) y.left = x.left;
            else y.right = x.left;
        }else{
            y = x;
            node z;
            for(z = x.right; z.left!=null; y = z, z = z.left);
            x.key = z.key;
            if(z.key<y.key) y.left = z.right;
            else y.right = z.right;
        }
    }
    static void inorder(node t){
        if(t==null) return;
        inorder(t.left);
        sb.append(' ').append(t.key);
        inorder(t.right);
    }
    static void preorder(node t){
        if(t==null) return;
        sb.append(' ').append(t.key);
        preorder(t.left);
        preorder(t.right);
    }
}
class node{
    public int key;
    public node left;
    public node right;
    node(int key){
        this.key = key;
        left = right = null;
    }
}

Measured memory_bytes: 102212
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int t,x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	if(y+2*z<=x){
		t=(x-z)/(y+z);
		printf("%d\n",t);
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const ll mod = 1e9+7;
// combination c;
// c(n, k); => nCk
struct combination {
    const int max = 510000;
    vector<long long> fact, ifact, inv;
    combination() {
        fact.resize(max);   // i!
        ifact.resize(max);  // (i!)^(mod-2)
        inv.resize(max);    // i^(mod-2)
        fact[0] = fact[1] = 1;
        ifact[0] = ifact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fact[i] = fact[i-1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
            ifact[i] = ifact[i-1] * inv[i] % mod;
        }
    }

    long long operator()(int n, int k) {
        if (n < k) return 0;
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
};

int main() {
    int n, k; cin >> n >> k;
    combination c;
    repf(i,1,k+1) {
        ll ans = c(n-k+1, i) * c(k-1, i-1) % mod;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 12160
#include <stdio.h>

int main()
{
    int i, s=0;
    char a[4], b[4];

    scanf("%s %s", a, b);

    for(i=0; i<3; i++)
    {
        if(a[i] == b[i])
            s++;
    }
    printf("%d\n", s);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

#define ll long long



int main()
{
    double w,h,x,y;
    cin >> w>>h>>x>>y;

    double h_dash = h/2;
    double w_dash = w/2;

    int flag=0;//複数あるかどうかのflag
    double S;//面積S

    if(h_dash == y && w_dash == x) flag = 1;

    S = (h*w)/2;
    cout << S << " " << flag << endl;

}

Measured memory_bytes: 384