akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
typedef long long ll;
const ll Inf=4e18;
ll gi() {
    ll x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,f[N],s[N];
ll a,b,x[N];
int getsum(int l,int r) {
    if(l>r) return 0;
    if(!l) return s[r];
    else return (s[r]-s[l-1]+mod)%mod;
}
int main() {
    cin>>n>>a>>b;
    if(a<b) swap(a,b);
    for(int i=1;i<=n;i++) x[i]=gi();
    x[0]=-Inf;x[n+1]=Inf;
    f[0]=s[0]=1;
    int l=0,r=0;
    for(int i=1;i<=n+1;i++) {
        while(r+1<i&&x[i]-x[r+1]>=a) r++;
        if(i>=2&&x[i-1]-x[i-2]<b) l=i-2;
        if(x[i]-x[i-1]>=a) f[i]=f[i-1];
        f[i]=(f[i]+getsum(l,min(i-2,r)))%mod;
        s[i]=s[i-1];
        if(x[i+1]-x[i-1]>=b) s[i]=(s[i]+f[i])%mod;
    }
    printf("%d\n",f[n+1]);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 1792
L,x[1<<17];d[20][1<<17];i,k,l,r,m;
main(n){
	for(scanf("%d",&n);i<n;)scanf("%d",++i+x);
	for(scanf("%d\n",&L);k<20;k++)for(i=0;i++<n;)
		if(k)d[k][i]=d[k-1][d[k-1][i]];
		else for(l=0,r=n+1;r-l>1;d[k][i]=l)x[m=l+r>>1]>x[i]+L?r=m:(l=m);
	for(gets(x);~scanf("%d%d",&l,&r);printf("%d\n",m+1))
		for(l>r&&(l^=r^=l^=r),m=0,k=20;k--;)d[k][l]<r?m+=1<<k,l=d[k][l]:0;
}

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

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

  int n, k;
  cin >> n >> k;
  vector<int> p(n);

  rep(i,n) cin >> p[i];
  rep(i,n) p[i]++;

  int s = 0;
  int mx = 0;
  queue<int> q;

  rep(i,n){
    s += p[i];
    q.push(p[i]);
    if(q.size() > k){
      s -= q.front();
      q.pop();
    }
    if(q.size() == k){
      mx = max(mx,s);
    }
  }

  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);

  return 0;

}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n, a[17][17], dp[66000]={0}, pc, sc[66000]={0};
    cin >> n;
    rep(i,0,n-1){
    	rep(j,0,n-1){
    		cin >> a[i][j];
    	}
    }
    rep(bit,1,(1<<n)-1){
    	ll pc = __builtin_popcountll(bit);
    	vc st;
    	rep(i,0,n-1) if(bit&(1<<i)) st.pb(i);
    	rep(i,0,pc-1){
    		rep(j,i+1,pc-1){
    			sc[bit] += a[st[i]][st[j]];
    		}
    	}
    	dp[bit] = sc[bit];
    	for(ll b3=(bit-1)&bit;b3>0;b3=(b3-1)&bit){
    		chmax(dp[bit], dp[bit-b3] + sc[b3]);
    	}
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

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

int main()
{
	const int N = 3;

	vector<vector<int>> a(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}

	int n; cin >> n;
	vector<int> b(n); for (int i = 0; i < n; i++) cin >> b[i];

	string ans = "No";

	vector<vector<bool>> f(N, vector<bool>(N,false));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {			
			for (int k = 0; k < n; k++) {
				if (a[i][j] == b[k]) f[i][j] = true;
			}
		}
	}

	if (f[0][0] == true && f[0][1] == true && f[0][2] == true) ans = "Yes";
	else if(f[1][0] == true && f[1][1] == true && f[1][2] == true) ans = "Yes";
	else if (f[2][0] == true && f[2][1] == true && f[2][2] == true) ans = "Yes";
	else if (f[0][0] == true && f[1][0] == true && f[2][0] == true) ans = "Yes";
	else if (f[0][1] == true && f[1][1] == true && f[2][1] == true) ans = "Yes";
	else if (f[0][2] == true && f[1][2] == true && f[2][2] == true) ans = "Yes";
	else if (f[0][0] == true && f[1][1] == true && f[2][2] == true) ans = "Yes";
	else if (f[2][0] == true && f[1][1] == true && f[0][2] == true) ans = "Yes";
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  set<string> se;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    se.insert(s);
  }
  cout << se.size() << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 19200
def main ():
    antennas= []
    max     = 0
    for i in range(6):
        if i < 5:
            antennas.append(int(input()))
        else:
            max = int(input())
    print (distance_comparison(max,antennas))

def distance_comparison(max,antennas):
    memo = []
    for i in range(len(antennas)):
        compnum = i+1
        for j in range(len(antennas[compnum:])):
            append_data = abs(antennas[i] - antennas[compnum])
            if append_data <= max:
                memo.append(append_data)
            else:
                return ":("
            compnum+=1
    return "Yay!"


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;

	if ((A * B) & 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    vector<int> h;
    int h_tmp;
    int ans=0;
    bool done = false;
    int start_i = 0;
    int end_i;
    int min_v;
    int count_w = 0;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> h_tmp;
        h.push_back(h_tmp);
    }
    while(true){
        start_i = 0;
        while(h[start_i]==0){
            if(start_i==n-1){
                done=true;
                break;
            }
            start_i++;
        }
        if(done){
            break;
        }
        min_v = h[start_i];
        end_i=start_i+1;
        while(h[end_i]!=0){
            if(min_v>h[end_i]){
                min_v=h[end_i];
            }
            end_i++;
            if(end_i==n){
                break;
            }
        }
        //cout << min_v << " " << start_i << " " << end_i << " " << count_w << endl;
        for(int i=start_i; i<end_i; i++){
            h[i] -= min_v;
        }
        count_w += min_v;
    }
    cout << count_w << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>v[n+1], dp[n+1];
	for(int i = 0; i < n; i++){
		int a, b, c;
		cin >> a >> b >> c;
		v[i].push_back(a);
		v[i].push_back(b);
		v[i].push_back(c);
		dp[i].push_back(0);
		dp[i].push_back(0);
		dp[i].push_back(0);
	}
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];
	for(int i = 1; i < n; i++){
			dp[i][0] = v[i][0]+max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = v[i][1]+max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = v[i][2]+max(dp[i-1][0], dp[i-1][1]);
			
	}
	cout << *max_element(dp[n-1].begin(), dp[n-1].end()) << "\n";
	return 0;
}

Measured memory_bytes: 14512
#include <stdio.h>

int main()
{
    int n, a[100], max=0, min=1000, i;
    scanf("%d\n", &n);
    for (i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if (a[i] > max) max = a[i];
        if (a[i] < min) min = a[i];
    }
    printf("%d\n", max - min);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    string s;
    int n,k;
    cin >> n >> k;
    cin >> s;
    s[k-1]=s[k-1]-'A'+'a';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    int cnt = 0;
    int i;
    scanf("%d %d %d",&a,&b,&c);
    for(i = a;i <= b;i++){
        if(c % i == 0)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
long long int a=1000000007;
long long int adder(long long int x,long long int y)
{
    x+=y;
    if(x>a)
     x=x-a;

     return x;
}
int main()
{
    long long int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(long long int i=0;i<n;i++)
    {
        for(long long int j=0;j<m;j++)
        {
            cin>>arr[i][j];
        }
    }
    long long int v[n][m];
    for(long long int i=0;i<n;i++)
    {
        for(long long int j=0;j<m;j++)
        {
            v[i][j]=0;
        }
    }
    v[0][0]=1;
    
    for(long long int i=0;i<n;i++)
    {
        for(long long int j=0;j<m;j++)
        {   
            for(long long int row=i;row<=i+1;row++)
            { long long int col=j;
                if(row==i)
                {
                   col=j+1;
                }
                if(row<n && col<m && arr[row][col]!='#')
                {
                    v[row][col]=adder(v[row][col],v[i][j]);
                }
            }
        }
    }
    cout<<v[n-1][m-1]%a;
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+'){
      ++ans;
    }else{
      --ans;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i, a, b) for (int i = a; i < b; i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int, int> s
#define lpair pair<LL, LL>
#define MAXN 100004

int main() {
    int n, d, ans;
    cin >> n >> d;
    ans = n / (2 * d + 1);
    if (n % (2 * d + 1) != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N;
    cin >> N;
    if (N % 2 == 1) {
        cout << N * 2 << endl;
    } else {
        cout << N  << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        int x=(int(log10(i))+1);
        if(x%2==1)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char c[100];
	scanf("%s",c);
	int i,j,k,m=0,l=strlen(c);
	for(i=0;i<l;i++)
	{
		k=0;
		for(j=0;j<l;j++)
		{
			if(c[i]==c[j]) k++;
		}
		if(k%2!=0)
		{
			m=1;
			break;
		}  
	}
	if(m==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

double pi = 3.14159265359;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a, b;
	double h, m; cin >> a >> b >> h >> m;
	h *= 30;
	h += m*0.5;
	m *= 6;
	double arg = 2*pi*abs(h-m)/360;
	cout << fixed << setprecision(20) << sqrt(a*a+b*b-2*a*b*cos(arg)) << endl;
	
	return 0;
}

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

int main() {
    int N,i,A,c=0,r=0;
    cin >> N;
    map<int,int> t;

    for(i=0; i<N; i++) {
        cin >> A;
        if(t.count(A))
            t.at(A)++;
        else
            t[A] = 1;
    }

    for(auto p : t)
        if(p.second%2 == 0)
            c++;
    if(c%2)
        r--;

    cout << t.size()+r << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int R[1000], H[1000];

long long B, A, N;

double ret;

priority_queue<double> retheight;

int main()
{
	double maxtime = -1;

	cin >> N >> A >> B;
	cout << max(0LL,(B*(N - 1) + A) - (A * (N - 1) + B) + 1 ) << endl;

	return 0;
}

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

signed main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  if((a+b)>(c+d)) {cout << "Left";}
  else if((a+b)==(c+d)) {cout << "Balanced";}
  else if((a+b)<(c+d)) {cout << "Right";}
}

Measured memory_bytes: 3524
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std; typedef long long ll;
typedef pair<ll,ll> P;

int main() {
  ll n,a,b; cin>>n>>a>>b;
  ll h[n]; for(int i=0;i<n;i++) cin>>h[i];
  ll ng=0, ok=1e9;
  while(ok-ng>1) {
    ll md=(ng+ok)/2;
    ll h2[n];
    for(int j=0;j<n;j++) h2[j]=max(0LL,h[j]-md*b);
    ll sm=0;
    for(int i=0;i<n;i++) sm+=h2[i]/(a-b)+(h2[i]%(a-b)!=0);
    if (sm<=md) ok=md; else ng=md;
    //cout<<sm<<" "<<md<<" "<<endl;
  }
  cout<<ok<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <unistd.h>
#include <vector>

using namespace std;

class UnionFind {
  vector<int> parent;
  vector<int> rank;
  int num;
  /*
  int find(int n) {
    for (int i = 0; i < n; i++) { // avoid infinite loop
      if (n < 0 || n >= num)      // check array bounds.
        return -1;
      if (n == parent[n])
        return n;
      n = parent[n]; }
    return -1;
  }
  */

public:
  UnionFind(int n) :num(n){
    parent = vector<int>(n);
    rank = vector<int>(n, 0);
    for (int i = 0; i < n; i++) {
      parent[i] = i;
    }
    //cerr << "uf(" << n << ") created!" <<  endl;
  }

  int find(int n) {
    //sleep(1);
    //cerr << "find:" << n << " parent[" << n <<"]=" <<parent[n] <<  endl;
    if (n == parent[n])
      return n;
    int root = this->find(parent[n]);
    parent[n] = root;
    rank[n] = 0;
    return root;
  }

  bool same(int a, int b) {
    a = this->find(a);
    b = this->find(b);
    return a == b;
  }
  void unite(int a, int b) {

    a = this->find(a);
    b = this->find(b);
    if(a==b) return;
    if (rank[a] > rank[b]) {
      parent[b] = a;
    } else if (rank[a] < rank[b]) {
      parent[a] = b;
    } else {
      rank[a]++;
      parent[b] = a;
    }
  }
};

enum com {
  UNITE = 0,
  SAME = 1,
};

int main() {
  int n, q, com, x, y;
  cin >> n >> q;
  UnionFind uf(n);

  for (int i = 0; i < q; i++) {
    cin >> com >> x >> y;
    //cerr << "com:" << com <<" x:" << x << " y:" << y << endl;
    switch (com) {
    case UNITE:
      uf.unite(x, y);
      break;
    case SAME:
      cout << (uf.same(x, y) ? 1 : 0) << endl;
    }
  }
}



Measured memory_bytes: 3180
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define max 101
#define INF 200000000
int color[max],p[max],n;
int m[max][max],d[max];
void prim(){
  int mincost,u,i;
  p[0]=-1;
  for(i=1;i<n;i++)d[i]=INF;
  while(1){
    mincost = INF;
    for(i=0;i<n;i++){
      if(color[i]!=1&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF)break;
    color[u]=1;
    for(int j=0;j<n;j++){
      if(color[j]!=1&&m[u][j]!=0)
	if(d[u]+m[u][j]<d[j]){
	  d[j]=m[u][j]+d[u];
	  p[j]=u;
	  color[j]=-1;
	}
    }
  }
}
int main(){
  int u,k,v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      cin>>m[u][v];
    }
  }
  prim();
  for(int i=0;i<n;i++)
    cout<<i<<" "<<((d[i]!=INF)?d[i]:-1)<<endl;

  return 0;
}



Measured memory_bytes: 3128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		int[] v = new int[N];
		int[] c = new int[N];
		for(int i = 0; i < N; i++)
			v[i] = sc.nextInt();
		for(int i = 0; i < N; i++)
			c[i] = sc.nextInt();
		for(int i = 0; i < N; i++)
			if(v[i]>c[i])
				ans += (v[i]-c[i]);
		System.out.println(ans);
	}

}

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

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

  ll res=0;
  vector<int> R(n+1, 0);
  vector<int> G(n+1, 0);
  vector<int> B(n+1, 0);
  rep(i, n) if (s[i]=='R') R[i+1]++;
  rep(i, n) if (s[i]=='G') G[i+1]++;
  rep(i, n) if (s[i]=='B') B[i+1]++;
  rep(i, n) R[i+1]+=R[i];
  rep(i, n) G[i+1]+=G[i];
  rep(i, n) B[i+1]+=B[i];

  vector<int> num(n, 0);
  rep(i, n) {
    if (s[i]=='R') num[i]=1;
    if (s[i]=='G') num[i]=2;
    if (s[i]=='B') num[i]=3;
  }
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int k=2*j-i;
      if (s[i]==s[j]) continue;
      int tmp=num[i]+num[j];
      if (tmp==3) {
        res+=B[n]-B[j+1];
        if ((k<n)&&(s[k]=='B')) res--;
      }
      if (tmp==5) {
        res+=R[n]-R[j+1];
        if ((k<n)&&(s[k]=='R')) res--;
      }
      if (tmp==4) {
        res+=G[n]-G[j+1];
        if ((k<n)&&(s[k]=='G')) res--;
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3712
import math
n = int(input())

root = int(math.sqrt(n))
for i in range(root, 0, -1):
    if n%i == 0:
        a = i
        b = n // i
        break

cnt = 1
while b // 10 >= 1:
    cnt += 1
    b = b // 10
print(cnt)

Measured memory_bytes: 3060
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare (inline read-byte)
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (read-byte in nil 0))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setq minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
	 (let* ((byte (%read-byte)))
	   (if (<= 48 byte 57)
	       (setq result (+ (- byte 48) (the (integer 0 #.(floor most-positive-fixnum 10)) (* result 10))))
	       (return (if minus (- result) result))))))))

(defun main ()
  (let* ((a-num (read))
	 (b-num (read))
	 (m-num (read))
	 (a-price (make-array a-num))
	 (b-price (make-array b-num))
	 (price 1000000))
    (dotimes (n a-num)
      (setf (aref a-price n) (read-fixnum)))
    (dotimes (n b-num)
      (setf (aref b-price n) (read-fixnum)))
    (dotimes (i m-num)
      (let* ((a-disc-idx (read-fixnum))
	     (b-disc-idx (read-fixnum))
	     (disc-price (read-fixnum))
	     (result (- (+ (aref a-price (1- a-disc-idx)) (aref b-price (1- b-disc-idx))) disc-price)))
	(if (< result price) 
	    (setq price result))))
    (setq a-price (sort a-price #'<))
    (setq b-price (sort b-price #'<))
    (if (< (+ (aref a-price 0) (aref b-price 0)) price)
	(setq price (+ (aref a-price 0) (aref b-price 0))))
    (format t "~a~%" price)))

(main)


Measured memory_bytes: 22500
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int x;
    cin >> x;
    cout << x * x * x << endl;

}

Measured memory_bytes: 3176
/**
 * @author torith
 * @date 2018-10-23
 */

#include <bits/stdc++.h>

using namespace std;

vector<int> edges[100];
int match[100];

bool dfs(int v, bool * visited){
    for (auto &u : edges[v]) {
        if (visited[u]) continue;
        visited[u] = true;
        if (match[u] == -1 || dfs(match[u],visited)){
            match[u] = v;
            return true;
        }
    }
    return false;
}

int main(){

    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<pair<int,int>> red;
    vector<pair<int,int>> blue;

    for (int i = 0; i < N; ++i) {
        int a,b;
        cin >> a >> b;
        red.push_back(make_pair(a,b));
    }

    for (int i = 0; i < N; ++i) {
        int a,b;
        cin >> a >> b;
        blue.push_back(make_pair(a,b));
        for (int j = 0; j < N; ++j) {
            if (red[j].first < a && red[j].second < b) {
                edges[j].push_back(i);
            }
        }
    }

    memset(match, -1 ,sizeof(match));

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        bool v[100] = {};
        if(dfs(i,v)) ans ++;
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), s(n, 0);
    vector<pair<ll, ll>> bc(m);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    rep(i, m)
    {
        cin >> bc[i].second >> bc[i].first;
    }
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());

    ll now = 0;
    for (int i = 0; i < m; i++)
    {
        for (ll j = now; j < min(now + bc[i].second, n); j++)
        {
            s[j] = bc[i].first;
        }
        now += bc[i].second;
        if (now >= n)
        {
            break;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += max(a[i], s[i]);
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

class Main{
    public static int[] L;
    public static int[] R;
    public static int count = 0;
    
    public static void mergeSort(int A[], int left, int right){
	
	if( (left+1) < right ){
	    
	    int mid = (left + right)/2;
	    mergeSort(A, left, mid);
	    mergeSort(A, mid, right);
	    merge(A, left, mid, right);
	}	
    }
    
    public static void merge(int A[], int left, int mid, int right){
	int i,j;
	int n1 = mid - left;
	int n2 = right - mid;

	for(i=0 ; i<n1 ; i++){
	    L[i] = A[left + i];
	}
	for(j=0 ; j<n2 ; j++){
	    R[j] = A[mid + j];
	}

	L[n1] = 2147483647;
	R[n2] = 2147483647;
	i = 0;
	j = 0;

	for(int k=left ; k<right ; k++){
	    if(L[i] <= R[j]){
		count++;
		A[k] = L[i];
		i++;
	    }
	    else {
		count++;
		A[k] = R[j];
		j++;
	    }
	}
    }
    
    public static void main(String[] args){
	L = new int[500000];
	R = new int[500000];
	int i;
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	int A[] = new int[500000];
	for(i=0 ; i<n ; i++){
	    A[i] = scan.nextInt();
	}

	mergeSort(A, 0, n);
	for(i=0 ; i<n-1 ; i++){
	    System.out.print(A[i]+" ");
	}
	System.out.println(A[i]);
	System.out.println(count);
	
	
    }

    
    
    
    
    
}




Measured memory_bytes: 177476
import java.util.Scanner;

public class Main {
	static  int c=1;
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int ans=0,i;
		boolean flag=false;
		int a=stdin.nextInt();
		int b=stdin.nextInt();
		for(i=a;i<=b;i++){
			String si=new String(""+i);
			int length=si.length();
			int  min=0;
			int max=length-1;
			while(min<max){
				if(si.charAt(min++)==si.charAt(max--))
					flag=true;

				else {
					flag=false;
					break;
				}
			}
			if(flag){
				ans++;
				flag=false;
			}
		}
		System.out.println(ans);
	}
}

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

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    while(a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int a[3];
	REP(i, 3) cin >> a[i];
	sort(a, a + 3, std::greater<int>());
	cout << (a[0] * 10 + a[1]) + a[2] << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main{
		public static void main(String[] args){
       		Scanner ti = new Scanner(System.in);
            int d = ti.nextInt();
            int t = ti.nextInt();
            int s = ti.nextInt();
          	float c;
           	c = (float)d/(float)s;
            if(c <= t)
     			System.out.println("Yes");
            else
            	System.out.println("No");
       }	
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
int f[3];
bool is_not_fake(int x){
    f[0] = f[1] = f[2] = 0;
    f[x%3]++;
    while (x > 2) {
        x /= 3;
        x -= 1;
        f[x%3]++;
    }
    return (f[0] != 0 && f[1] != 0 && f[2] != 0) ? true : false;
}
void Main(){
    int N = read(), ans = 0, b;
    vector<vector<int> > a(30000, vector<int>(2, 0));
    a[0][0] = 3;
    a[1][0] = 5;
    a[2][0] = 7;
    for (int i = 0; i< 30000; i++) {
        b = (i+1)*3;
        if (a[i][0] > N) break;
        if (a[i][1] == 0 && is_not_fake(i)) a[i][1] = 1;
        if (a[i][1] == 1) ans++;
        if (a[i][0] == 777777753) break;
        if (b >= 30000) continue;
        if (a[i][1] == 1) a[b][1] = a[b+1][1] = a[b+2][1] = 1;
        a[b][0] = 10*a[i][0]+3;
        a[b+1][0] = 10*a[i][0]+5;
        a[b+2][0] = 10*a[i][0]+7;
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007
#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define endl "\n"
#define f first
#define s second

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
                    tree_order_statistics_node_update>
                    ordered_set;

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define printa(v) for (auto i: v) cout << i << " ";

bool poss(vi& arr, ll k, ll m) {
    ll tot = 0;
    REP(i, 0, arr.size())
        tot += arr[i]/m + bool(arr[i]%m) - 1;
    if (tot <= k)
        return true;
    return false;
}

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    vi arr(n);
    REP(i, 0, n)
        cin >> arr[i];
    ll l = 1, h = *max_element(all(arr)) + 1, mid = (l+h)/2;
    while (l < h) {
        if (poss(arr, k, mid))
            h = mid;
        else
            l = mid + 1;
        mid = (l+h)/2;
    }
    cout << l << endl;
}


Measured memory_bytes: 4732
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val a = long()
    val b = long()
    val c = long()
    val p = Math.min(b, c)
    val q = Math.min(c - p, a)
    val r = if (c - p - q > 0) 1 else 0
    val s = b - p
    println(p * 2 + q + r + s)
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

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

int main() {
  long N,K;
  cin>>N>>K;
  long x=N%K;
  long y=K-x;
  cout << min(x,y)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


signed main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i];
    a[i]-=(i+1);
  }
  sort(all(a));
  int mid=a[n/2];
  int ans=0;
  rep(i,n)ans+=abs(a[i]-mid);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    string s;
    cin>>s;
    if(s[0]=='9' ||s[1]=='9'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }



    return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val l1 = readLine()!!.split(" ").map { it.toInt() }
    val l2 = readLine()!!.split(" ").map { it.toInt() }
    var s = 0
    l2.forEach  { s += it }
    var c = 0
    l2.forEach { if (4*l1[1]*it >= s) c++ }
    println(if (c >= l1[1]) "Yes" else "No")
}

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

int n, a, b, ans = 0;

bool check(int num) {
	int sum = 0, digit = 10;
	//cout << "num:" << num << endl;
	while (num >= digit/10) {
		sum += (num - num / digit*digit) / (digit/10);
		digit *= 10;
	}
	//cout << "sum:" << sum << endl;
	return sum >= a && sum <= b;
}

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

	for (int i = 1; i <= n; i++) {
		if(check(i))ans += i;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] llist = new long[n];
        long[] rlist = new long[n];
        long[] list = new long[n];
        for(int i=0;i<n;i++) list[i] = Long.parseLong(sc.next());
        for(int i=0;i<n;i++){
            if(i==0){
                llist[i] = list[i];
                rlist[n-i-1] = list[n-i-1];
            }else{
                llist[i] = llist[i-1] + list[i];
                rlist[n-i-1] = rlist[n-i] + list[n-i-1];
            }
        }
        long ans = Math.abs(llist[0] - rlist[1]);
        for(int i=0;i<n-1;i++){
            ans = Math.min(ans,Math.abs(llist[i] - rlist[i+1]));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 65948
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    int[] p = new int[sc.nextInt()];

    for(int pIdx=0;pIdx<p.length;pIdx++){
      p[pIdx]=sc.nextInt();
    }

    int count=0;
    for(int pIdx = 1;pIdx<p.length-1;pIdx++){
      if(isMatch(p[pIdx-1],p[pIdx],p[pIdx+1]))count++;
    }
    System.out.println(count);
  }

  static boolean isMatch(int pm1, int p0, int pp1) {
    return (!(p0 < pm1 && p0 < pp1)) && !(p0 > pm1 && p0 > pp1);
  }
}


Measured memory_bytes: 22100
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n y

n mai 2000
y en 2*10^7

10000
5000
1000
 */
int n,y;
int satu[] = {10000, 5000,1000};
int mai[3];

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

  bool found = false;
  REP(i,n+1){
    REP(j,n-i+1){
      LOG("i=%d, j=%d\n", i,j);
      int k = n - (i+j);
      mai[0] = i;
      mai[1] = j;
      mai[2] = k;
      int sum=0;
      REP(l,3){
        sum+=satu[l]*mai[l];
      }

      if(sum == y){
        LOG("hit!\n");
        found = true;
        break;      
      }
    }
    if(found)
      break;
  }

  if(!found){
    cout << -1 << " " << -1 << " " << -1<<endl;
    return 0;
  }

  REP(i,3)
    cout<<mai[i]<<" ";

  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
ct = [0] * N
edges = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  edges[a-1].append(b-1)

for _ in range(Q):
  p, x = map(int, input().split())
  ct[p-1] += x

ans = [0] * N
ans[0] = ct[0]
q = [(0, ct[0])]
while len(q):
  i, c = q.pop()
  for t in edges[i]:
    ans[t] = c + ct[t]
    q.append((t, ans[t]))
print(' '.join(map(str, ans)))

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

using namespace std;
int main(void){
    // Your code here!
    int n,m,ans=0;
    priority_queue<int> q;
    std::cin >> n>> m;
    pair<int,int> p[100000];
    for (int i = 0; i < n; i++) {
        std::cin >> p[i].first >>p[i].second;
    }
    sort(p,p+n);
    int i=0;
    for (int j = m-1; j >= 0; j--) {
        while(i<n&&p[i].first+j<=m){
            q.push(p[i++].second);
        }
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <math.h>
int main( void ){
	int n;
	double x1, y1, x2, y2, x3, y3, xp, yp, r, a, b, c;
	for(scanf("%d",&n); n--; ){
		scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3 );
		a = x1*x1+y1*y1;
		b = x2*x2+y2*y2;
		c = x3*x3+y3*y3;
		xp = ((b-a)*(y3-y1)-(c-a)*(y2-y1))/((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))*0.5;
		if(fabs(y2-y1)<1e-8){y2=y3;x2=x3;b=c;}
		yp = ((b-a)*0.5-(x2-x1)*xp)/(y2-y1);
		r = sqrt( (x1-xp)*(x1-xp) + (y1-yp)*(y1-yp) );
		printf("%.3f %.3f %.3f\n", xp, yp, r );
	}
	return 0;
}

Measured memory_bytes: 0
cnt = 0

n = int(input())
h = [int(_) for _ in input().split()]

now = [0] * len(h)

while True:
    cnt += 1
    chk = False
    for i in range(n):
        if h[i] == now[i]:
            if chk == True:
                break
        else:
            now[i] += 1
            chk = True
    if chk == False:
        cnt -= 1
        break

print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
	long n;
	cin >> n;
  //vector<long> A;
	long A[n];
	long x;
	long B[n];
  B[0] = 0;
	for(long i = 1; i < n; i++){
      cin >> x;
      //A.push_back(x - 1);
      A[i] = x - 1;
      B[i] = 0;
    }
  
  
  for(long i = 1; i < n; i++){
      B[A[i]]++;
    }
	
  for(long i = 0; i < n; i++){
      printf("%ld\n", B[i]);
    }
    return 0;
}


Measured memory_bytes: 6872
lst = list(input().split())
for num, i in enumerate(lst):
    if 'apple' in i:
        n = i.find('apple')
        lst[num] = i[:n] +'peach' + i[n+5:]

    elif 'peach' in i:
        n = i.find('peach')
        lst[num] = i[:n] + 'apple' + i[n+5:]
    
    else:
        pass

print(*lst)


Measured memory_bytes: 5568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
	ll N;
	std::vector<ll> A(5);
	cin >> N;
	for (int i = 0; i < 5; i++)
	{
		cin >> A[i];
	}
	ll m  = A[0];

	for (int i = 1; i < 5; i++)
	{
		m = min(m,A[i]);
	}

	ll ceil = (N % m == 0 ? N/m : N/m + 1);

	cout << ceil + 4 << endl;

	return 0;
}

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

int main(){
    int N, M;
    cin >> N;
    vector<string> s(N);
    for (int i=0; i<N; i++) cin >> s.at(i);
    cin >> M;
    vector<string> t(M);
    for (int i=0; i<M; i++) cin >> t.at(i);

    vector<int> a(N);

    for (int i=0; i<N; i++){
        int sum=0;
        string b = s.at(i);
        for (int j=0; j<N; j++){
            if (s.at(j) == b) sum++;
        }
        for (int j=0; j<M; j++){
            if (t.at(j) == b) sum--;
        }
        a.at(i) = sum;
    }

    int max=0;
    for (int i=0; i<N; i++){
        if (a.at(i) > max) max = a.at(i);
    }

    cout << max << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
root=[-1]*n
def r(x): #-1の項が何番目かを特定
  if root[x]<0: #x番目が-1ならx(>=0)を返す
    return x 
  else: #x番目が0以上なら-1の項に到達するまで回す
    root[x]=r(root[x]) 
    return root[x] #-1の項に到達したらその項が何番目かを返す
def unite(x,y):
  x=r(x)
  y=r(y)
  if x==y: #同じ項に到達した場合は処理の必要なし
    return
  root[x]+=root[y] #-1ずつ加算していく
  root[y]=x #-1を足した後は適当な数に変える(重複回避)
for i in range(m):
  a,b=map(int,input().split())
  a-=1 #リストの序数に合わせる
  b-=1
  unite(a,b) #各人間がどのくらい友達がいるか
ans=0
for i in range(n):
  ans=max(ans,-root[i]) #最多保有友人数が何人か
print(ans)


Measured memory_bytes: 13240
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t K, T;
  cin >> K >> T;
  int64_t max_volume = INT64_MIN;
  for (int64_t i = 0; i < T; ++i) {
    int64_t a;
    cin >> a;
    if (a > max_volume) {
      max_volume = a;
    }
  }
  cout << max(0L, max_volume - 1 - (K - max_volume)) << endl;
  return 0;
}


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

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

int dist(pii a, pii b)
{
    int dy = a.first - b.first;
    int dx = a.second - b.second;
    if(0 <= dy*dx){
        dy = abs(dy);
        dx = abs(dx);
        return dy + max(0, dx - (dy+1-min(a.first,b.first)%2)/2);
    }
    else{
        dy = abs(dy);
        dx = abs(dx);
        return dy + max(0, dx - (dy + min(a.first, b.first)%2)/2);
    }
}

int main()
{
    int m, n;
    while(scanf("%d%d", &m, &n), m){
        int s;
        scanf("%d", &s);
        pii conv[10];
        rep(i, s)
            scanf("%d%d", &conv[i].second, &conv[i].first);

        int d[101][101];
        rep(i, n) rep(j, m){
            d[i+1][j+1] = INF;
            rep(k, s)
                d[i+1][j+1] = min(d[i+1][j+1], dist(pii(i+1, j+1), conv[k]));
        }

        int t, ans = 0;
        scanf("%d", &t);
        rep(i, t){
            int x, y;
            scanf("%d%d", &x, &y);

            int cnt = 0;
            rep(j, n) rep(k, m)
                cnt += dist(pii(j+1, k+1), pii(y, x)) < d[j+1][k+1];
            ans = max(ans, cnt);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3172
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int a, b, c;
	cin >> a >> b >> c;
 
	if(a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <string>
using namespace std;

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

	int *h = new int[N];

	for(int i=0; i<N; i++)
	{
		int t;
		cin>>t;
		h[i]=t;
	}

	//iに行くまでの最小コストを保存し続ければよい
	int *cost = new int[N];
	cost[0] = 0;
	for(int i=1; i<N; i++)
	{
		vector<int> list;
		for(int j=max(0,i-K); j<i; j++)
		{
			//cout<<j<<endl;
			list.push_back(abs(h[i]-h[j])+cost[j]);
		}
		cost[i] = *min_element(list.begin(),list.end());
	}

	cout<<cost[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int n ;
    scanf ("%d",&n) ;
    for (int i=0; i<n+1; i++) {
        long long l[100] ;
        if (i==0) {
            l[i]=2 ;
        } else if (i==1) {
            l[i]=1 ;
        } else {
            l[i]=l[i-1]+l[i-2] ;
        }
        if (i==n){
            printf ("%lld\n",l[i]) ;
        }
    }
    return 0 ;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int N = 1e5+10;
struct edge{ int to,cost; };
vector< edge > G[N*3];

void dikstra(int s,int t){
  typedef pair<int, int> P;
  const int INF = 1 << 30;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(N*3,INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  if(d[t] == INF) cout << -1 << endl;
  else cout << d[t]/3 << endl;
}

signed main(){

  int n,m; cin >> n >> m;
  for(int i = 0; i < m; i++){
    int u,v; cin >> u >> v;
    u--,v--;
    for(int j = 0; j < 3; j++){
      G[u + j*N].push_back({v + ((j+1)%3)*N,1});
    }
  }
  int s,t; cin >> s >> t;
  s--,t--;

  dikstra(s,t);

  return 0;
}


Measured memory_bytes: 18944