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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int N;
int C[505], S[505], F[505];

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N-1){
        cin>>C[i]>>S[i]>>F[i];
    }

    REP(i,0,N){
        if(i == N-1){
            cout<<0<<endl;
            break;
        }
        int t = S[i];
        REP(j,i,N-1){
            if(t == S[i] || (t % F[j] == 0 && S[j] <= t)){
                t += C[j];
            }else{
                for(int l = S[j]; ; l += F[j]){
                    if(t <= l){
                        t = l;
                        t += C[j];
                        break;
                    }
                }
            }
        }
        cout<<t<<endl;
    }

    return 0;
}


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

int main() 
{
  string S;
  string T;
  
  cin >> S >> T;
  if(T.erase(T.size()-1)== S)
  {
    cout << "Yes" << endl;
  }
  else
  {cout << "No" << endl;
  }
  
}


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

#define _GLIBCXX_DEBAC
using namespace std;
	
int findx(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}



int main() {
	int n, Y;
	cin >> n >> Y;
	int x = -1, y = -1, z = -1;
	for (int i = 0; i <= n; i ++ ) {
		for (int j = 0; j+i <= n; j++) {
			int c = n - i - j;
			int total = 10000 * i + 5000 * j + 1000 * c;
			if (total == Y) {
				x = i;
				y = j;
				z = c;
			}
		}
	}
	cout << x << " " << y << " " << z << endl;
	return 0;
}










Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
r = 1
ans = 0
cnt = 0

for l in range(0, n):
    if l == 0:
        if s[l] == '0':
            cnt += 1

    if l > 0 and s[l] == '1' and s[l-1] == '0':
        cnt -= 1

    while True:
        # print('\n', l, r)
        # print('count:', cnt)
        if r > n - 1:
            length = r - l
            ans = max(ans, length)
            break

        if s[r] == '0' and s[r-1] == '1':
            if cnt < k:
                cnt += 1
            else:
                # print('over!')
                length = r - l
                ans = max(ans, length)
                break
        r += 1

print(ans)


Measured memory_bytes: 41712
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

char s[20]; int n;

int main() {
    scanf("%s",s+1); n=strlen(s+1);
    ll ans=0;
    for (re int i=0;i<1<<(n-1);++i) {
        ll now=s[1]-'0';
        for (re int j=2;j<=n;++j) {
            if (i&(1<<(j-2))) ans+=now,now=s[j]-'0';
            else now=now*10+s[j]-'0';
        }
        ans+=now;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;
using namespace std;
 
int main(){
    int N; cin >> N;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    
    float num=N/2;
    if (N%2!=0){
        cout << 0;
        return 0;
    }
    else{
        int sa=A[num]-A[num-1];
        if (sa==0) cout <<0;
        else cout << sa;
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  vector<ll> a(n);
  ll al = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    al ^= a[i];
  }
  for(int i = 0; i < n; i++){
    cout << (al ^ a[i]) << ' ';
  }
  cout << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<algorithm>
using namespace std;

int main(void){
  int n,x;
  int a,b;
  long long ans =0;

  scanf("%d %d %d",&n,&x,&a);

  for(int i=0;i<n-1;i++){
    scanf("%d",&b);
    if(a+b>x){
      ans+=a+b-x;
      a = max(0,x-a);
    }
    else
      a = b;
  }

  printf("%lld\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int x,y,k;
  string s,t,ans;
  cin >> s >> t;
  ans="";
  for (int i=0;i < max(s.size(),t.size());i++){
    ans+=s[i];
    if (i!=t.size()) ans+=t[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main(){
    int n;
    std::cin >> n;
    if (n == 1){
        std::cout << "1" << std::endl;
        return 0;
    }
    int a = 1, b = 1;
    for (int i = 1; i < n; i++){
        int c = a + b;
        a = b;
        b = c;
    }
    std::cout << b << std::endl;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,dp[8][8],a,b,ans,used[8];
void dfs(ll x,ll y){
    if(y==n)ans++;
    used[x]=1;
    for(int i=0;i<n;i++){
        //cout<<dp[x][i]<<" "<<((1<<i)&y)<<endl;
        if(!used[i]&&dp[x][i])dfs(i,y+1);
    }
    used[x]=0;
    return ;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        dp[a][b]++;
        dp[b][a]++;
    }
    dfs(0,1);
    cout<<ans<<endl;
}


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

int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> c(N);
    vector<vector<int>> A(N, vector<int> (M));
    for (int i = 0; i < N; i++) {
        cin >> c[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans  = 1e9;
    for (int bit = 0; bit < (1 << N); bit++) {
        vector<int> val(M);
        int price = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                for (int j = 0; j < M; j++) {
                    val[j] += A[i][j];
                }
                price += c[i];
            }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
            if (val[i] < X) ok = false; 
        }
        if (ok) ans = min(ans, price);
    }
    if (ans == 1e9) cout << -1 << endl;
    else cout << ans << endl; 
}

Measured memory_bytes: 3604
#include<cstdio>

int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(W-r<x||H-r<y||x<r||y<r){
		printf("No\n");
	}else{
		printf("Yes\n");
	}

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  for (int i = 0; i < 4; i++){
   if (s.at(i) == '+') count ++;
   else count --;
  }
  cout << count << endl;
}

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

using namespace std;

const int N = 2e5 + 7;
int n;
int m;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    vector < long double > vt(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> vt[i];
    }
    int ptr = 0;

    for(int i = m ; i < n ; ++i) {
        if(vt[i] > vt[ptr++]) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }
    return 0;
}



Measured memory_bytes: 6364
#include <stdio.h>
#include <math.h>

int main(void)
{
	double r;
	
	scanf("%lf", &r);
	
	//????????¢???
	double S = r * r * M_PI; 
	
	//?????¨?????????
	double C = 2 * r * M_PI;
	
	printf("%f %f\n",S, C);
	
	return 0;
}

Measured memory_bytes: 2644
#include <stdio.h>

int a[5][10];

void arrange(void)
{
	int i,j;
	for(i = 0;i < 5;i++){
		for(j = 0;j < 9;j++){
			if(a[i][j + 1] == 0 && a[i][j] != 0){
				a[i][j + 1] = a[i][j];
				a[i][j] = 0;
				j = -1;
			}
		}
	}
	return;
}

int delblock(void)
{
	int i,j,ret = 0;
	for(j = 0;j < 10;j++){
		for(i = 0;i < 3;i++){
			if(a[i][j] != 0 && a[i][j] == a[i + 1][j] && a[i][j] == a[i + 2][j]){
				if(i + 3 < 5 && a[i][j] == a[i + 3][j]){
					if(i + 4 < 5 && a[i][j] == a[i + 4][j]){
						a[i + 4][j] = 0;
					}
					a[i + 3][j] = 0;
				}
				a[i][j] = a[i + 1][j] = a[i + 2][j] = 0;
				ret = 1;
			}
		}
	}
	return ret;
}

int main(void)
{
	int H,i,j,sum,afsum;
	while(1)
	{
		for(j = 0;j< 10;j++)
			for(i = 0;i < 5;i++)
				a[i][j] = 0;
		sum = afsum = 0;
		scanf("%d",&H);
		if(H == 0)
			break;
		for(j = 10 - H;j< 10;j++){
			for(i = 0;i < 5;i++){
				scanf("%d",&a[i][j]);
				sum += a[i][j];
			}
		}
		while(delblock()){
			arrange();
		}
		for(j = 0;j< 10;j++)
			for(i = 0;i < 5;i++)
				afsum += a[i][j];
		printf("%d\n",sum - afsum);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int n;
  cin >> n;
  priority_queue<double> Q;
  rep(i,n) {
    double v;
    cin >> v;
    Q.push(-v);
  }
  while( Q.size() >= 2 ) {
    double x = -Q.top(); Q.pop();
    double y = -Q.top(); Q.pop();
    Q.push(-(x+y)/2.0);
  }
  printf("%.10f\n",-Q.top());
  compute();
  return 0;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

arr=Vector{String}()
function dfs(n,cnt,s)
    if cnt==n
        push!(arr,s)
    else
        l=length(collect(Set(collect(s))))
        for i in 'a':'a'+l
            dfs(n,cnt+1,join([s,i]))
        end
    end
end

function main()
    n=parseInt(readline())
    dfs(n,0,"")
    sort!(arr)
    for i in arr
        println(i)
    end
end
main()

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

int main(){
  int n,m;cin>>n>>m;
  int sum=0;
  rep(i,m){int a;cin>>a;sum+=a;}
  cout<<(sum>n?-1:n-sum);
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    fast;
ll a,b;
cin>>a>>b;
cout<<(a*b)/__gcd(a,b);

   }

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

using namespace std;

vector<int> colorLL;
vector<vector<int> > graf;
vector<pair<int,int> > edge;
map<pair<int,int>,int> res;
int colM;
void dfs(int n){
	//cout<<"nodo "<<n<<endl;
	int color=1;
	for(int i=0;i<graf[n].size();i++){
		int w=graf[n][i];
		if(colorLL[w]==0){
			if(color==colorLL[n]) color++;
			colorLL[w]=color;
			res[make_pair(n,w)]=color;
			dfs(w);
			colM=max(colM,color);
			color++;
		}
	}
}
int main(){
	int n,a,b;
	cin>>n;
	graf.resize(n);
	colorLL.assign(n,0);
	colM=0;
	for(int i=0;i<n-1;i++){
		cin>>a>>b;
		a--;b--;
		graf[a].push_back(b);
		graf[b].push_back(a);
		edge.push_back(make_pair(a,b));
	}
	colorLL[0]=-1;
	dfs(0);
	cout<<colM<<endl;
	for(int i=0;i<edge.size();i++){
		cout<<res[edge[i]]<<endl;
	}
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	(a < b) ? 
		(b < c) ? 
			cout << a << " " << b << " " << c << endl :
			(a < c) ?
				cout << a << " " << c << " " << b << endl :
				cout << c << " " << a << " " << b << endl :
		(a < c) ?	
			cout << b << " " << a << " " << c << endl :	
			(b < c) ?
				cout << b << " " << c << " " << a << endl :	
				cout << c << " " << b << " " << a << endl ;	
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> /*inline*/ bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX = 3030;

signed main() {
    string s, t;
    cin >> s >> t;
    int dp[MAX][MAX] = {0};
    
    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < t.length(); j++) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }
    
    string ans = "";
    int i = s.length(), j = t.length();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else {
            ans += s[i-1];
            i--; j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    /*
    for (int i = 0; i <= s.length(); i++) {
        for (int j = 0; j <= t.length(); j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 36096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = max({a * 10 + b + c, a + b * 10 + c, a + b + c * 10});
    cout << ans << endl;

    return 0;
}

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

void fun(ll n , ll s){
 ll a[n];
 ll sum=0;
 ll r,l;
 l=0;
 r=n-1;
 ll ans=n;
 for(ll i=0;i<n;i++){cin>>a[i];sum+=a[i];}
 if(sum<s)ans=0;
 while(l<=r && ans){
 if(a[l]<a[r]&&sum-a[l]>=s){

    sum-=a[l++];ans--;

 }else if(sum-a[r]>=s){
    sum-=a[r--];ans--;

 }else break;;;


}
 cout << ans << "\n";
}
int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll n,m;
 cin >>n>>m;
 cout << (n+m)%24 << "\n";
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    V<int> x(n), y(n), h(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            int H = -1;
            for(int k = 0; k < n; k++){
                if(h[k] > 0){
                    int tmp = h[k] + abs(x[k] - i) + abs(y[k] - j);
                    if(H == -1){
                        H = tmp;
                    }else{
                        if(H != tmp){
                            H = -2;
                            break;
                        }
                    }
                }
            }
            if(H == -2) continue;

            for(int k = 0; k < n; k++){
                if(h[k] == 0){
                    int tmp = abs(x[k] - i) + abs(y[k] - j);
                    if(H > tmp){
                        H = -2;
                        break;
                    }
                }
            }
            if(H == -2) continue;

            cout << i << " " << j << " " << H << endl;
            return 0;
        }
    }

    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Console.WriteLine(input[0] <= input[1] ? input[0] : input[0] - 1);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    int f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline ll readll() {
    ll f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll n;
int main(){
    cin>>n;
    if(n%2==0||n%5==0){
        cout<<-1<<endl;
        return 0;
    }
    ll rem=7,p=1;
    while(rem%n!=0){
        rem=(rem*10+7)%n;
        p++;
    }cout<<p<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3724
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int row[10100];
int colum[10100];

int main() {
  int n;
  while (scanf("%d", &n), n) {
  REP(i, n) {
    scanf("%d", &row[i]);
  }
  REP(i, n) {
    scanf("%d", &colum[i]);
  }
  sort(row, row + n);
  reverse(row, row + n);
  sort(colum, colum + n);
  reverse(colum, colum + n);
  REP(y, n) {
    REP(x, n) {
      if (x < row[y]) {
        if (colum[x] == 0) { goto NO; }
        colum[x]--;
      } else {
        if (colum[x] != 0) { goto NO; }
      }
      if (x == row[y]) { break; }
    }
  }
  puts("Yes");
  continue;
NO:;
   puts("No");
}
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int x = in.nextInt();

			long ans = 0;
			for (long b = 1; b <= 1000; b++) {
				for (long e = 2; e <= 1000; e++) {
					long t = power(b, e);
					if (t <= x) {
						ans = Math.max(ans, t);
					} else {
						break;
					}
				}
			}
			out.println(ans);

		}
	}
	static long power(long a, long e) {
		long ret = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0) {
				ret = (ret * a);
			}
			a = (a * a);
		}
		return ret;
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
from heapq import*
i=input
for _ in'_'*int(i()):
 n,s,x,*y=int(i()),0,[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>r:x+=(k,l,r),
  else:y+=(n-k,r,l),
 for x in(x,y):
  x.sort();n,*h=len(x),
  while n:
   n-=1
   while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[1]
  for*_,r in x+h:s+=r
 print(s)

Measured memory_bytes: 39884
S = input()
count = 0
flag = 0
for s in S:
    count += 1
    if count % 2 == 1:
        if s != "R" and s != "U" and  s != "D":
            flag = 1
    if count % 2 == 0:
        if s != "L" and s != "U" and s != "D":
            flag = 1
if flag == 0:
    print("Yes")
elif flag == 1:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  const int MAX_N = 55555;

  std::vector<bool> is_prime(MAX_N + 1, true);

  is_prime[0] = is_prime[1] = false;

  for (int i = 2; i * i <= MAX_N; i ++)
    if (is_prime[i])
      for (int k = i + i; k <= MAX_N; k += i)
        is_prime[k] = false;

  int N;

  std::cin >> N;

  for (int i = 1, c = 0; c < N; i += 10)
    if (is_prime[i]) {
      std::cout << i << ' ';

      c ++;
    }
  
  std::cout << std::endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(p[i] != i+1) cnt++;
  }
  if(cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
 }


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
struct pos{
    ll y;
    ll x;
};
int main(){
    ll h,w,m;
    cin >> h >> w >> m;
    vector<pair<ll,ll>> hk(h);
    vector<pair<ll,ll>> wk(w);
    for(int i = 0;i < h;i++)hk[i].first = 0,hk[i].second = i;
    for(int i = 0;i < w;i++)wk[i].first = 0,wk[i].second = i;
    map<pair<ll,ll>,ll> mp;
    for(int i = 0;i < m;i++){
        ll inh,inw;
        cin >> inh >> inw;
        inh--,inw--;
        mp[make_pair(inh,inw)]++;
        hk[inh].first++;
        wk[inw].first++;
    }
    ll res = 0;
    for(auto i:mp){
        res = max(res,hk[i.first.first].first + wk[i.first.second].first - 1);
    }
    //sort(hk.rbegin(),hk.rend());
    sort(wk.rbegin(),wk.rend());
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(mp[make_pair(i,wk[j].second)] == 0){
                res = max(res,hk[i].first + wk[j].first);
                j = w;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 50100
s=list(input())
t=list(input())
S=len(s)
T=len(t)
count=0
ans=1000
for i in range(S-T+1):
  count=0
  for j in range(T):
    if s[i+j]!=t[j]:
      count+=1
  ans=min(ans,count)
print(ans)

Measured memory_bytes: 9120
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    x,y=map(int, readline().rstrip().split())
    z=2*x-y
    if z%3 != 0 or z < 0:
        print(0)
        return
    b=z//3
    a=x-2*b
    if a < 0:
        print(0)
        return
    mod=10**9+7
    n=a+b
    r=min(a,b)

    ans=1

    for i in range(r):
        ans=(ans*(n-i))%mod
        ans=(ans*pow(i+1,mod-2,mod))%mod
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define PB push_back
#define ALL(obj) (obj).begin(), (obj).end()

int x[10], y[10];

double GetDistBetween(int i, int j) {
  int dx = x[i] - x[j];
  int dy = y[i] - y[j];
  return pow(dx*dx + dy*dy, 0.5);
}

/***** MAIN *****/
signed main() {
  int n, fact = 1;
  double sum = 0;
  scanf("%d", &n);
  REP(i, n) cin >> x[i] >> y[i];

  vector<int> v(n);
  REP(i, n) {
    v[i] = i;
    fact *= i+1;
  }

  do {
    REPS(i, 1, n) sum += GetDistBetween(v[i], v[i-1]);
  } while(next_permutation(ALL(v)));
  cout << fixed << setprecision(10) << sum/fact;

  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    ll h=0,w=0;
    cin>>h>>w;

    if(h==1 || w==1)ans=1;
    else if(h%2==1)ans=w*(h/2)+(w+1)/2;
    else ans=w*(h/2);

    //cout <<fixed<<setprecision(16)<< << endl;
    
    cout<<ans<<endl;
    
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from math import factorial
MOD = 10**9 + 7

n = int(input())

dist = np.diff(list(map(int, input().split())))
L = np.cumsum(np.array([1 / x for x in range(1, n)]))
n_1 = factorial(n-1) % MOD

# fac = [1] * n
# for i in range(1,n):
# 	fac[i] = fac[i-1] * i % MOD

# print(int(np.sum(L * dist * n_1)) % MOD)
# ans = 0
# for l, d in zip(L, dist):
#     print("l d ", l * d)
#     ans += l * d
#     ans %= MOD

ans = 0
tmp = 0
for i, d in enumerate(dist):
    tmp += pow(i+1, MOD-2, MOD)
    ans += tmp * d
    ans %= MOD

# print(n_1)
print(ans * n_1 % MOD)
# print(int(np.sum(dist * L * n_1) % MOD))

Measured memory_bytes: 31308
import java.util.*;

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

    int i = 0;
    while (i < S.length() && S.charAt(i) == '1') {
      i++;
    }
    if (i == S.length() || K <= i) {
      System.out.println(1);
    } else {
      System.out.println(S.charAt(i));
    }
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
int main()
{
  int n;
  int y,m,d;
  int day=0;//count

  int date[3][10]={ {20,20,20,20,20,20,20,20,20,20},
		    {20,19,20,19,20,19,20,19,20,19},
		    {20,19,20,19,20,19,20,19,20,19} };

  scanf("%d",&n);
  for(;n>0;n--){
    scanf("%d %d %d",&y,&m,&d);
    day=date[y%3][m-1]-d;
    m++;
    d=0;
    if(m==11){
      y++;
      m=1;
    }
    if(y==1000)//999テ・ツケツエ10テヲツ慊暗ァツ板淌」ツ?セテ」ツつ古」ツ?ョテ・ツ?エテ・ツ青?
      printf("%d\n", day+1);
    else{//テ」ツ?敕」ツつ古、ツサツ・テ・ツ、ツ?

      while(1){
	day+=date[y%3][m-1];
	m++;   
	if(m==11){
	  y++;
	  m=1;
	}
	if(y==1000)	  
	  break;
      }
    printf("%d\n",day+1);
    }
  }
}

Measured memory_bytes: 596
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None
c = []


def f(B):
    ans = 0
    for idx in range(len(B)):
        if B[len(B) - idx - 1] == "1":
            ans += ((-2)**idx)

    return ans


def is_lower(idx, c_value, N):
    add_value = 0
    for i in range(idx, -1, -1):
        if c[i] > 0:
            add_value += c[i]

    return c_value + add_value < N


# idx未満の添え字の数を引いて行った結果，
# 目的の数を上回ればidxを引く必要がある
def is_over(idx, c_value, N):
    sub_value = 0
    for i in range(idx, -1, -1):
        if c[i] < 0:
            sub_value += c[i]

    return c_value + sub_value > N


def main():
    N = int(input())
    c_value = None

    if N == 0:
        print(0)
        return

    for i in range(50):
        c.append((-2)**i)

    if N > 0:
        tmpsum = 0
        for i in range(50):
            if c[i] > 0:
                tmpsum += c[i]

            if tmpsum >= N:
                idx = i
                c_value = c[i]
                break

        ans = "1"

        for c_idx in range(idx - 1, -1, -1):
            if c[c_idx] < 0:
                if is_over(c_idx - 2, c_value, N):
                    ans += "1"
                    c_value += c[c_idx]
                else:
                    ans += "0"
            else:
                if is_lower(c_idx - 2, c_value, N):
                    ans += "1"
                    c_value += c[c_idx]
                else:
                    ans += "0"

    else:
        tmpsub = 0
        for i in range(50):
            if c[i] < 0:
                tmpsub += c[i]

            if tmpsub <= N:
                idx = i
                c_value = c[i]
                break

        ans = "1"

        for c_idx in range(idx - 1, -1, -1):
            if c[c_idx] < 0:
                if is_over(c_idx - 2, c_value, N):
                    ans += "1"
                    c_value += c[c_idx]
                else:
                    ans += "0"
            else:
                if is_lower(c_idx - 2, c_value, N):
                    ans += "1"
                    c_value += c[c_idx]
                else:
                    ans += "0"

    print(ans)


main()


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

int n, k, a[110], dp[110][110][260], ans = 0;
int MOD = 1000000007;

signed main()
{
  cin >> n >> k;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }

  for(int i = 0; i < n; i++){
    dp[0][i][0] = 1;
  }
  
  for(int i1 = 0; i1 < n; i1++){
    for(int i3 = 0; i3 < n; i3++){
      for(int j = 0; j <= 255; j++){
	dp[i1 + 1][i3 + 1][j ^ a[i3 + 1]] += dp[i1][i3][j] * (i1 + 1);
	dp[i1 + 1][i3 + 1][j ^ a[i3 + 1]] %= MOD;
      }
      for(int j = 0; j <= 255; j++){
	dp[i1 + 1][i3 + 1][j] += dp[i1 + 1][i3][j];
	dp[i1 + 1][i3 + 1][j] %= MOD;
      }
    }
  }
  
  for(int i = 1; i <= n; i++){
    ans += dp[i][n][k];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int n; scanf("%d", &n);
	long long arr[n];
	for (int i=0; i<n; i++) scanf("%lld", &arr[i]);
	sort(arr,arr+n);
	long long sum=0;
	int imp=-1;
	for (int i=0; i<n-1; i++) {
		sum+=arr[i];
		if (sum*2<arr[i+1]) {
			imp=i;
		}
	}
	printf("%d\n", n-imp-1);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  set<ll> st;
  for(int i=0;i<N;i++)st.insert(A.at(i));
  if(st.size()==N)cout<<"YES";
  else cout<<"NO";
}
  

Measured memory_bytes: 11136
n = int(input())

odd = [i for i in range(1,201,2)]
odd_y = [1 for i in range(1,201,2)]

for i in range(len(odd)):
    for k in range(1,i+1):
        if odd[i] % k == 0:
            odd_y[i] += 1
        else:
            pass

all = []

for i in range(len(odd_y)):
    if odd_y[i] == 8:
        all.append(odd[i])

# print(all)
count = 0
for i in all:
    if n >= i:
        count += 1

print(count)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (V.erase(remove((V).begin(), (V).end(), (a)), (V).end()))
#define REVERSE(v) (reverse((V).begin(), (V).end()))
#define LOWER_BOUND(v,a) (lower_bound((V).begin(), (V).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((V).begin(), (V).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

struct St
{
	int s;
	int t;
	St(int s, int t)
	{
		this->s = s;
		this->t = t;
	}
	bool operator < (const St &st) const
	{
		return (s < st.s);
	}
};

int N, C;
vector<St> st[31];
int cnt[100001];

signed main()
{
	cin >> N >> C;
	REP(i, N)
	{
		int s, t, c;
		cin >> s >> t >> c;
		st[c].push_back(St(s, t));
	}
	for (int i = 1; i <= C; i++)
	{
		SORT(st[i]);
	}

	for (int i = 1; i <= C; i++)
	{
		int end = -1;
		for (St& s : st[i])
		{
			if (s.s == end)
			{
				s.s++;
			}
			end = s.t;
			for (int j = s.s; j <= s.t; j++)
			{
				cnt[j]++;
			}
		}
	}

	int max = 0;
	for (int i = 0; i <= 100000; i++)
	{
		max = MAX(cnt[i], max);
	}
	cout << max << endl;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define INF 1e18 * 5
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


void solve() {
    int N,K;
    cin >> N >> K;
    vector<pair<ll,ll>> v(N);
    vector<ll> vx(N);
    vector<ll> vy(N);
    REP(i,N) {
        ll x,y;
        cin >> x >> y;
        v[i] = make_pair(x,y);
        vx[i] = x;
        vy[i] = y;
    }

    sort(ALL(vx));
    sort(ALL(vy));

    ll ans = INF;
    // x1,x2,y1,y2を決定
    REP(x1i,N-1) {
        FOR(x2i,x1i+1,N) {
            REP(y1i,N-1) {
                FOR(y2i, y1i+1,N) {
                    auto x1 = vx[x1i];
                    auto x2 = vx[x2i];
                    auto y1 = vy[y1i];
                    auto y2 = vy[y2i];

                    auto cnt = 0;

                    REP(i,N) {
                        auto x = v[i].first;
                        auto y = v[i].second;
                        auto cond1 = x1 <= x && x <= x2;
                        auto cond2 = y1 <= y && y <= y2;
                        if(cond1 && cond2) cnt++;
                    }

                    if(cnt >= K) chmin(ans,(x2-x1)*(y2-y1));

                }
            }
        }
    }

    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
 
    vector<ll> b(n - 1);
    for(int i = 0; i < n - 1; i++){
        cin >> b[i];
    }
 
    reverse(b.begin(), b.end());
 
    ll ans = 0;
    vector<ll> a(n);
    for(int i = 0; i < n - 1; i++){
        if(i == 0){
            a[i] = b[i];
        } else {
            a[i] = min(b[i], b[i - 1]);
        }
 
        if(i == n - 2){
            a[i] = min(b[i], b[i - 1]);
            a[i + 1] = b[i];
        }
    }
    
    for(int i = 0; i < n; i++) ans += a[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int h,w,n;
    cin>>h>>w>>n;

    int mx = max(h,w);
    cout<< (n+mx-1)/mx << endl;

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

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

int main() {
  int n; cin >> n;
  double ans = (double)((n  + 1)/ 2) / n;
  cout << setprecision(15) << ans << endl;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int X;

signed main(){
    cin>>X;
    if(X>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    if(n <= 999)
    {
        cout <<"ABC";
    }
    else 
    {
        cout <<"ABD";
    }
}


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

using ld = long double;
using point = std::complex<ld>;
using polygon = std::vector<point>;

constexpr ld eps = 1e-10;
constexpr ld pi = std::acos(-1.0);

ld dot(point const& a, point const& b) {
    return std::real(std::conj(a) * b);
}
ld cross(point const& a, point const& b) {
    return std::imag(std::conj(a) * b);
}

int ccw(point a, point b, point c) {
    b -= a; c -= a;
    if(cross(b, c) > eps) return 1;            // a -> b -> c : counterclockwise
    if(cross(b, c) < -eps) return -1;          // a -> b -> c : clockwise
    if(dot(b, c) < 0) return 2;                // c -> a -> b : line
    if(std::norm(b) < std::norm(c)) return -2; // a -> b -> c : line
    return 0;                                  // a -> c -> b : line
}

polygon convex_hull(std::vector<point> ps) {
    std::sort(std::begin(ps), std::end(ps),
              [](point const& p1, point const& p2) {
                  return std::real(p1) < std::real(p2)
                         || (std::real(p1) <= std::real(p2) && std::imag(p1) < std::imag(p2));
              });
    const int n = ps.size();
    int k = 0;
    polygon qs(2 * n);
    for(int i = 0; i < n; ++i) {
        while(k > 1 && ccw(qs[k - 2], qs[k - 1], ps[i]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for(int i = n - 2, t = k; i >= 0; --i) {
        while(k > t && ccw(qs[k - 2], qs[k - 1], ps[i]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k - 1);
    return qs;
}

ld area(polygon const& poly) {
    const int n = poly.size();
    ld res = 0;
    for(int i = 0; i < n; ++i) {
        res += cross(poly[i], poly[(i + 1) % n]);
    }
    return res / 2;
}

int main() {
    int n;
    cin >> n;
    vector<point> ps(n);
    for(int i = 0; i < n; ++i) {
        ld x, y;
        cin >> x >> y;
        ps[i] = point(x, y);
    }
    auto check = [&](vector<point> const& ps) {
        polygon poly = {ps[0], ps[1]};
        bool res = false;
        for(int i = 2; i < n; ++i) {
            const ld s1 = area(convex_hull(poly));
            poly.push_back(ps[i]);
            const ld s2 = area(convex_hull(poly));
            res |= fabs(s1 - s2) < eps;
        }
        return res;
    };
    bool ng = check(ps);
    reverse(begin(ps), end(ps));
    ng |= check(ps);

    cout << (!ng ? "Possible" : "Impossible") << endl;
}



Measured memory_bytes: 3324
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		int[] array = new int[26];
		int intTemp;
		while(scan.hasNext()){
			strIn += scan.nextLine();
		}
		for(int i = 0; i < strIn.length(); i++){
			intTemp = strIn.charAt(i);
			if('A' <= intTemp && intTemp <= 'Z'){
				array[intTemp - 'A']++;
			}else if('a' <= intTemp && intTemp <= 'z'){
				array[intTemp - 'a']++;
			}
		}
		for(int i = 0; i < array.length; i++){
			System.out.println((char)('a' + i) + " : " + array[i]);
		}

		scan.close();
	}
}

Measured memory_bytes: 17164
#include "bits/stdc++.h"
using namespace std;
long n, k, q;
 
int main() {
    cin >> n >> k >> q;
    vector<long> point(n, k-q);
    for(long i = 0; i < q; i++){
        long a;
        cin >> a;
        point[a-1] += 1;
    }
    for(long j = 0; j < n; j++){
        cout << ((point.at(j) > 0) ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 1408