akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <limits.h>
using namespace std;

int main(void)
{
	int n, now = 0, flag[101] = {};
	long ans = 0, an[100][100], min[100];

	cin >> n;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++)
			cin >> an[i][j];
		min[i] = LONG_MAX;
	}

	do {
		long key = LONG_MAX, key_i;
		flag[now] = 1;
		flag[100] = 0;

		for(int i = 0; i < n; i++) {
			if(an[now][i] != -1 && an[now][i] < min[i] && flag[i] == 0)
				min[i] = an[now][i];
			if(flag[i] == 0 && min[i] < key) {
				key = min[i];
				key_i = i;
			}
			if(flag[i] == 1)
				flag[100]++;
		}

		now = key_i;
		ans += key;

	}while(flag[100] != n - 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1236
n = int(input())
b = list(map(int, input().split()))

answer = 0

for i in range(n - 1):
    answer += b[i] * 2

    if i != n - 2:
        if b[i] < b[i + 1]:
            answer -= b[i + 1]
        else:
            answer -= b[i]

print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);  cin.tie(0) ; cout.tie(0);
#define pi 3.14159265359
#define pb emplace_back
#define mp make_pair
#define F first
#define S second
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<ii> vii;

int main()
{
    ll a , b , k;
    cin >> a>> b>> k;
        if (a > 0)
        {
            if (a >= k)
            {
                cout << (a-k) <<" " << b << endl;
                return 0;
            }
            else
            {
                k -= a;
                a = 0;
            }
        }
        
        if (b >= k )
        {
            cout << 0 << " " << (b-k) << endl;
        }
        else 
        {
            cout <<0 << " " << 0 << endl;
        }

   return 0;
}

Measured memory_bytes: 256
/*
				C++
				encoding: UTF-8
				Modified: <28/Sep/2019 06:27:01 PM>

				✪ H4WK3yE乡
				Mohd. Farhan Tahir
				Indian Institute Of Information Technology (IIIT), Gwalior
*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define         ll                     long long
#define         ve                     vector
#define         pb                     push_back
#define         endl                   "\n"
#define         ff                     first
#define         ss                     second
#define         pii                    pair<ll, ll>
#define         len(v)                 (v.size())
#define         all(v)                 v.begin(), v.end()
#define         reset(a, b)            memset(a, b, sizeof(a));
#define         fr(i, s, n)            for (ll i = s ; i < n ; ++i)
#define         dfr(i, s, n)           for (ll i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

bool prime (ll number) {
	if (number < 2) return false;
	if (number % 2 == 0) return (number == 2);
	ll root = sqrt (number);
	for (ll i = 3; i <= root; i += 2) {
		if (number % i == 0) return false;
	}
	return true;
}

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

set< ll > factors1;

void commDiv1 (ll n) {
	ll result = 0;
	for (ll i = 1; i <= sqrt (n) + 100; i++) {
		if (n % i == 0) {
			if (n / i == i) {
				factors1.insert (i);
			} else {
				factors1.insert (i);
				factors1.insert (n / i);
			}
		}
	}
}
set< ll > factors2;

void commDiv2 (ll n) {
	ll result = 0;
	for (ll i = 1; i <= sqrt (n) + 100; i++) {
		if (n % i == 0) {
			if (n / i == i) {
				factors2.insert (i);
			} else {
				factors2.insert (i);
				factors2.insert (n / i);
			}
		}
	}
}


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

	ll a, b;
	cin >> a >> b;
	commDiv1 (a);
	commDiv2 (b);


	ve< ll > arr;

	for (auto i : factors1) {
		if (factors2.find (i) != factors2.end ()) {
			arr.pb (i);
		}
	}

	int ans = 0;

	sort (all (arr));
	set< ll > s;

	fr (i, 0, len (arr)) {
		int f = 1;
		for (auto j : s) {
			if (gcd (arr[i], j) != 1) {
				f = 0;
				break;
			}
		}
		if (f) {
			ans++;
			s.insert (arr[i]);
		}
	}
	pr (ans);

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const double pi = 3.141592653589793238;

/*int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double hx = x / a / a;
  double facex = a * hx;
  const double facemax = a * b;
  double degree = 0;
  cout << facex << endl;
  cout << endl;
  while (a*sin(degree/180*pi)<=b*sin((pi/2)-(degree/180*pi))){
    double facei = facemax - ((a*sin(degree/180*pi)*a*cos(degree/180*pi)));
    cout << degree << endl;
    cout << facei << endl;
    cout << endl;
    if (facei <= facex){
      cout << degree << endl;
      return 0;
    }
    degree++;
  }
  while (degree<=90){
    double facei = (a*sin(degree/180*pi)*a*cos(degree/180*pi)) / 2;
    cout << degree << endl;
    cout << facei << endl;
    cout << endl;
    if (facei <= facex){
      cout << degree << endl;
      return 0;
    }
    degree++;
  }
  return 0;
}*/

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double s = x/a;
  double rad;
  if (s >= a * b / 2){
    double h = (2*(a*b-s))/a;
    rad = atan2(h,a);
  }
  else {
    double w = 2*s/b;
    rad = atan2(b,w);
  }
  double deg = (rad/(2*pi)) * 360;
  printf("%.10f\n", deg);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

void solve(long long N, std::vector<long long> B) {
    long long ans = 0;
    vector<long long> A(N, 1e9);
    for (int i = 0; i < B.size(); i++) {
        A[i] = min(A[i], B[i]);
        A[i + 1] = min(A[i+1], B[i]);
    }
    for(int i = 0 ; i < N ; i++)
        ans += A[i];
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> B(N - 1);
    for (int i = 0; i < N - 1; i++) {
        scanf("%lld", &B[i]);
    }
    solve(N, std::move(B));
    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 1010;

int n;
int a[N];
map<int, int> h;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++ ) scanf("%d", &a[i]);
	
	LL res = 0;
	for (int i = 0; i < n; i ++ )
	{
		if (h.count(i - a[i])) res += h[i - a[i]];
		h[a[i] + i] ++ ;
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 13816
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
//int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
	return 0;
}

Measured memory_bytes: 4352
s=sorted(list(input()))
t=sorted(list(input()))[::-1]
for i in range(min(len(s),len(t))):
  if(s[i]<t[i]):
    print('Yes')
    exit()
  elif(s[i]>t[i]):
    print('No')
    exit()
if(len(s)<len(t)):print('Yes')
else:print('No')

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int x,y,xx,yy;
  scanf("%d %d %d %d",&x,&y,&xx,&yy);
  printf("%d %d %d %d\n",xx-yy+y,yy+xx-x,x-yy+y,y+xx-x);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#define ll long long 
using namespace std;
const ll WY=1e9+7;
ll qpow(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%WY;
		b>>=1;
		a=a*a%WY;
	} 
	return ret;
}
ll dp[45][262150];
int main() {
	ll n,x,y,z,OK;
	scanf("%lld %lld %lld %lld",&n,&x,&y,&z);
	ll MAXN=(1<<(x+y+z))-1;
	OK=(1<<(x-1))|(1<<(x+y-1))|(1<<(x+y+z-1));
	dp[0][0]=1;
	for(ll i=0;i<n;i++)
	{
		for(ll S=0;S<=MAXN;S++)
		{
			for(ll k=1;k<=10;k++)
			{
				ll To=((S<<k)|(1<<(k-1)))&MAXN;//&MAXN 把高出x+y+z位的压掉 
				if((To&OK)==OK) continue;
				(dp[i+1][To]+=dp[i][S])%=WY;
			}
		}
	}
	ll ans=qpow(10,n);
	for(ll i=0;i<=MAXN;i++) ans-=dp[n][i];
	((ans%=WY)+=WY)%=WY;
	printf("%lld",ans);
	return 0;
}


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

int main(){
  int A,B = 0;
  cin >> A >> B;
  if(A == 1 && B == 2){
    cout << "3" << endl;
  }
  else if(B == 1 && A == 2){
    cout << "3" << endl;
  }
  else if(B == 3 && A == 2){
    cout << "1" << endl;
  }
  else if(B == 2 && A == 3){
    cout << "1" << endl;
  }
  else if(B == 1 && A == 3){
    cout << "2" << endl;
  }
  else if(B == 3 && A == 1){
    cout << "2" << endl;
  }
}

Measured memory_bytes: 256
import sys
from itertools import permutations
from math import factorial

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def distance2(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


def main():
    N = int(readline())
    C = [tuple(map(int, readline().split())) for _ in range(N)]

    dist = [[0] * N for _ in range(N)]
    for i in range(N):
        for j in range(i + 1, N):
            dist[i][j] = dist[j][i] = distance2(C[i][0], C[i][1], C[j][0], C[j][1])

    ans = 0
    for perm in permutations(range(N)):
        for i in range(N - 1):
            ans += dist[perm[i]][perm[i + 1]]

    print(ans / factorial(N))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
//	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int mod =  2019;
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        long mod=2019;
        long[] modinv = new long[200005];
        long t=1;
        for(int i=0;i<200005;i++) {
        	modinv[i]=modinv(t);
        	t=(t*10)%mod;
        }
        
        
        
        
        String S = sc.next();
        char[] c = S.toCharArray();
        long[] m = new long[c.length];
        long[] sum = new long[c.length];
        long tmp=1;
        for(int i=0;i<c.length;i++) {
        	m[i]=(tmp*(int)(c[c.length-1-i]-'0'))%mod;
        	if(i==0) {
        		sum[i]=m[i];
        	} else {
        		sum[i]=(sum[i-1]+m[i])%mod;
        	}
        	tmp=(tmp*10)%mod;
        }
        long ans=0;
        long[] an=new long[200000];
        an[0]=1;
        for(int i=1;i<200000;i++) {
        	an[i]=an[i-1]+i+1;
        }
        Arrays.sort(sum);
        int tt=0;
        for(int i=0;i<sum.length-1;i++) {
        	if(i==0&&sum[i]==0)tt++;
        	if(sum[i]==sum[i+1])tt++;
        	else {
        		ans=ans+tt*(tt+1)/2;
        		tt=0;
        	}
        }
        ans=ans+tt*(tt+1)/2;
/*        for(int i=0;i<c.length-1;i++) {
        	for(int j=i+1;j<c.length;j++) {
        		if(i==0) {
        			if(sum[j]==0)ans++;
        		} else {
            		if(((sum[j]-sum[i-1]+2019)*modinv[i])%mod==0) {
            			//System.out.println(i + "and" + j);
            			ans++;
            		}        			
        		}
        	}
        }*/
    	
    	
    	System.out.println(ans);
    	
        		
    }
    
	public static long pow(long a,long n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%mod;
	        }
	        a=(a*a)%mod;
	        n>>=1;
	    }
	    return res;
	}
 
	public static long modinv(long n) {
		return pow(n, mod-2)%mod;
	}
}

Measured memory_bytes: 47172
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void print(vector<long long> v){
    for(int i=0;i<v.size();i++){
        cout << v[i] << endl;
    }
    cout << endl;
}

void printBool(vector<bool> v){
    for(int i=0;i<v.size();i++){
        cout << v[i] << endl;
    }
    cout << endl;
}
int main(){
    long long n,tmp;
    cin >> n;
    vector<long long> a;
    vector<bool> isOK(n,false);
    vector<long long> sum(n,0);
    for(long long i=0;i<n;i++){
        cin >> tmp;
        a.push_back(tmp);
        isOK[i] = false;
    }
    sort(a.begin(),a.end());
    for(long long i=0;i<n;i++){
        tmp = a[i];
        if(i==0)
            sum[i] = tmp;
        else{
            sum[i] = sum[i-1] + tmp;
        }
    }
    long long count = 0;
    for(long long i = n-1;i >= 0;i--){
        if(i == n-1){
            count++;
            isOK[i] = true;
            continue;
        }
        if(2*sum[i] >= a[i+1] && isOK[i+1] == true){
            count++;
            isOK[i] = true;
            continue;
        }
    }
    cout << count << endl;
    return 0;
}


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

if n%9 == 0:
    if n//9 <10:
        print("Yes")
    else:
        print("No")
elif n%8 == 0:
    if n//8 < 9:
        print("Yes")
    else:
        print("No")
elif n%7 == 0:
    if n//7 <8:
        print("Yes")
    else:
        print("No")
elif n%6 == 0:
    if n//6 <7:
        print("Yes")
    else:
        print("No")
elif n%5 == 0:
    if n//5 <6:
        print("Yes")
    else:
        print("No")
elif n%4 == 0:
    if n//4 <5:
        print("Yes")
    else:
        print(No)
elif n<9:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int ans = m;
  REP(i,0,n-m) {
    int cnt_req_changes = 0;
    REP(k,0,m-1) {
      if(s[i+k] != t[k]) {
        cnt_req_changes++;
      }
    }
    if(cnt_req_changes < ans) {
      ans = cnt_req_changes;
    }
  }
  cout << ans;
}

int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3612
#include <iostream>

int main() 
{
  int n;
  std::cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) std::cin >> a[i];
  
  int max, nmax, maxnum;
  max = 0;
  nmax = 0;
  for (int i = 0; i < n; i++){
    if (a[i] <= nmax) continue;
    else if (a[i] <= max) {
      nmax = a[i];
    }
    else {
      max = a[i];
      maxnum = i;
    }
  }
  
  for (int i = 0; i < n; i++){
    if(i == maxnum) std::cout << nmax << std::endl;
    else std::cout << max << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];
int last[400][30];

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * ((i+1) - last[i+1][old]);
    s -= C[old] * ((i+1) - last[d][old]);
  }
  FOR(i,d,D){
    if(i!=d && t[i]==q) break;
    s += C[q] * ((i+1) - last[i+1][q]);
    s -= C[q] * ((i+1) - (d+1));
  }

  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = 0LL;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = score(tmp);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    REP(loop,100){
      int d = rand365(mt);
      int q = rand26(mt);
      int old = T[d];
      T[d] = q;
      ll tmp = score_2(T, max_score, d, old, q);
      if(max_score<tmp){
        max_score = tmp;
        FOR(i,d,D){
          if(T[i]==old) break;
          last[i+1][old] = last[d][old];
        }
        FOR(i,d,D){
          if(i!=d && T[i]==q) break;
          last[i+1][q] = (d+1);
        }
      }else{
        T[d] = old;
      }
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    vector<ll> seive(10000001,2);
    seive[1]=1;
    for(ll i=2;i<=10000000;i++)
    {
        ll j=2*i;
        while(j<=10000000)
        {
            seive[j]++;
            j+=i;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        sum+=(i*seive[i]);
    }
    cout<<sum;
}

Measured memory_bytes: 81336
import math


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

c = [-1]*N
c[0] = 0
c[1] = abs(h[0] - h[1])

for i in range(2, N):
	c[i] = min(abs(h[i] - h[i-1]) + c[i-1], abs(h[i] - h[i-2]) + c[i-2])

print(c[N-1])



Measured memory_bytes: 14480
#include <iostream>
#include <cmath>

using namespace std;

int a, b, c, d;
string s1,s2;
bool flag;
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin>>s1>>s2;
    for(int i=0;i<3;i++){
        if(s1[i]!=s2[2-i]){
            flag=true;
            break;
        }
    }
    cout<<(flag?"NO":"YES");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <utility>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <set> 
#include <vector>
#include <limits.h>
#include <math.h>

#define ll long long 

using namespace std; 
int n;
int main(void)
{
	int s = 0;
	scanf("%d", &n);
	for (int i = 1;; i++)
	{
		if ((1 << i) > n)
		{
			s = i;
			break;
		}
	}
	printf("%d\n", 1 << (s - 1));


	return false;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> to;
vb seen;

void dfs(int v, int ban) {
    for (Edge nv : to[v]) {
        if (nv.id == ban) continue;
        if (seen[nv.to]) continue;
        seen[nv.to] = true;
        dfs(nv.to, ban);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    to.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(Edge{b, i});
        to[b].pb(Edge{a, i});
    }
    int ans = 0;
    rep(ban, m) {
        seen = vb(n, false);
        seen[0] = true;
        dfs(0, ban);
        bool flag = true;
        rep(i, n) {
            if (!seen[i]) flag = false;
        }
        if (!flag) ans++;
    }
    cout << ans << endl;
    
}

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

using namespace std;

class student {
public:
    int st[50], ed[50];
    int num, cnt;
    student() { num = 0; cnt = 0; }
};

int main()
{
    int N; // PC数
    int M; // 学生数

    while (cin >> N >> M, N || M) {
        int r;  // 利用記録数
        int q;  // 質問数
        vector<student> std(M + 1);

        // 登録
        cin >> r;
        for (int i = 0; i < r; i++) {
            int t, n, m, s;  // s(1: ログイン, 0: ログアウト), 時刻tにPCnで学生mが
            cin >> t >> n >> m >> s;

            if (s == 1) { // ログイン
                if (std[m].cnt == 0) {  // まだログインしていない
                    std[m].st[std[m].num] = t;
                }
                std[m].cnt++;
            }
            else { // ログアウト
                if (std[m].cnt == 1) 
                    std[m].ed[std[m].num++] = t;
                std[m].cnt--;
            }
        }

        // 質問
        cin >> q;
        for (int i = 0; i < q; i++) {
            int ts, te, m;
            int ans = 0;

            cin >> ts >> te >> m;

            for (int j = 0; j < std[m].num; j++) {
                if (std[m].ed[j] <= ts)
                    continue;
                if (std[m].st[j] >= te)
                    break;
                
                if (std[m].st[j] <= ts && std[m].ed[j] >= te) {
                    ans += te - ts;
                    break;
                }
                if (std[m].st[j] <= ts && std[m].ed[j] < te)
                    ans += std[m].ed[j] - ts;
                else if (std[m].st[j] >= ts && std[m].ed[j] >= te) {
                    ans += te - std[m].st[j];
                    break;
                }
                else if (std[m].st[j] >= ts && std[m].ed[j] < te) 
                    ans += std[m].ed[j] - std[m].st[j];
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5056
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	double aa, bb;
	aa = (double)a;
	bb = (double)b;
	printf("%.10f\n", (aa*bb)/(aa+bb));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
ll calc(ll x, ll y, ll L, ll T){
  if(T*2 < abs(x-y)){
    return 0;
  }
  ll remain = T*2 - abs(x-y);
  return 1+remain/L;
}
 
int main(){
  int N, L, T;
  cin >> N >> L >> T;
  vector<ll> X, W;
  vector<int> ans;
 
  rep(i,N){
    int x, w;
    cin >> x >> w;
    X.push_back(x);
    W.push_back(w);
 
    if(w == 1){
      ans.push_back((x+T)%L);
    }else{
      ans.push_back(((x-T)%L+L)%L);
    }
  }

  int base = ans[0];
  sort(ALLOF(ans));

  //cout << " " << base << endl;
  //rep(i,ans.size()){
  //  cout << ans[i] << " ";
  //}
  //cout << endl;
  
  int SZ = ans.size();
  int cnt = 0;
  if(W[0] == 1){
    rep(i,X.size()){
      if(W[i] == 2){
        cnt += calc(X[0], X[i], L, T);
      }
    }
    //0番だったやつはcnt番になっていてbaseにある
    vector<int> ret(SZ);
    int b = 0;
    rep(i,ans.size()){
      if(ans[i] == base){
        b = i;
        break;
      }
    }
    if(ans[b] == ans[(b+1)%SZ]){
      b = (b+1)%SZ;
    }
    rep(j,ans.size()){
      ret[(cnt+j)%SZ] = ans[(b+j)%SZ];
    }
    

    //cout << cnt << endl;
    rep(i,ret.size()){
      cout << ret[i] << endl;
    }
    
  }else{
    rep(i,X.size()){
      if(W[i] == 1){
        cnt += calc(X[0]+L, X[i], L, T);
      }
    }
    //cout << " " << cnt << " " << base << " " << ((-cnt)%SZ+SZ)%SZ << endl;
    //0番だったやつは-cnt番になっていてbaseにある
    vector<int> ret(ans.size());
    int b = 0;
    rep(i,ans.size()){
      if(ans[i] == base){
        b = i;
        break;
      }
    }
    rep(j,ans.size()){
      ret[((-cnt+j)%SZ+SZ)%SZ] = ans[(b+j)%SZ];
    }

    
    rep(i,ret.size()){
      cout << ret[i] << endl;
    }
    
  }
  
  
  return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#define N 53
#define M 207
#define IL inline
#define REP(a,b,c) for(a=b;a<=c;a++)
#define PER(a,b,c) for(a=b;a>=c;a--)
using namespace std;
typedef long long lol;
const int mod=1e9+7;
int n,m,k,dfn[N],low[N],tk,S[M],top;
int head[N],lt[M],nt[M],ap=1,pw[N],vis[N],col;
lol fac[M],inv[M],ans=1;
IL int gcd(int a,int b){int t;while(b)t=a%b,a=b,b=t;return a;}
IL lol qpow(lol a,int b){lol res=1;while(b){if(b&1)res=res*a%mod;a=a*a%mod,b>>=1;}return res;}
IL void link(int a,int b){
	lt[++ap]=b,nt[ap]=head[a],head[a]=ap;
	lt[++ap]=a,nt[ap]=head[b],head[b]=ap;
}
IL int rd(){
	int res=0;char c;while((c=getchar())<'0'||c>'9');
	while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res;
}
IL lol polya(int n){
	int i,res=0;
	REP(i,1,n)res=(res+pw[gcd(i,n)])%mod;
	return res*qpow(n,mod-2)%mod;
}
IL lol C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
IL void solve(int x){
	if(top==1)ans=ans*k%mod,top=0;
	else{
		int u,v,etot=0,vtot=0;++col;
		do{
			etot++;
			u=lt[S[top]],v=lt[S[top]^1];
			if(vis[u]!=col)vtot++,vis[u]=col;
			if(vis[v]!=col)vtot++,vis[v]=col;
		}while(S[top--]!=x);
		if(etot==vtot)ans=(ans*polya(etot))%mod;
		else ans=ans*C(etot+k-1,k-1)%mod;
	}
}
IL void tarjan(int u,int f){
	dfn[u]=low[u]=++tk;int x,v;
	for(x=head[u];x;x=nt[x])if((v=lt[x])!=f){
			if(!dfn[v]){
				S[++top]=x;tarjan(v,u),low[u]=min(low[u],low[v]);
				if(low[v]>=dfn[u])solve(x);
			}
			else{
				low[u]=min(low[u],dfn[v]);
				if(dfn[v]<dfn[u])S[++top]=x;
			}
		}
}
int main(){
  n=rd(),m=rd(),k=rd();int i,j=m+k;fac[0]=pw[0]=1;
  REP(i,1,j)fac[i]=fac[i-1]*i%mod;inv[j]=qpow(fac[j],mod-2);
	PER(i,j,1)inv[i-1]=inv[i]*i%mod;REP(i,1,n)pw[i]=(1LL*pw[i-1]*k)%mod;
	REP(i,1,m)link(rd(),rd());
	REP(i,1,n)if(!dfn[i])
		tarjan(i,0);
	printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<LL,LL>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n;
    cin >> n;
    LL a[n+5];
    for (LL i=1;i<=n;i++) cin >> a[i];
    LL cnt[100005];
    memset (cnt,0,sizeof(cnt));
    LL ans = 0;
    for (LL i=1;i<=n;i++) {
        cnt[a[i]]++;
        ans += a[i];
    }
    LL q;
    cin >> q;
    while (q--) {
        LL x,y;
        cin >> x >> y;
        LL t = cnt[x];
        cnt[x] -= t;
        cnt[y] += t;
        ans -= x*t;
        ans += y*t;
        cout << ans << endl;
    }
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 5136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  rep(i,n)
  {
    cin>>h[i];
  }
  sort(all(h));
  int res=1e9+7;
  rep(i,n-k+1)
  {
    chmin(res,h[i+k-1]-h[i]);
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		double s =0.0,c = 0.0;
	     Scanner sc = new Scanner(System.in);
	     double r = sc.nextDouble();
	     s = r * r * Math.PI;
	     c = 2 * r * Math.PI;
	     System.out.println(String.format("%10f %10f",s,c));
	}
}



Measured memory_bytes: 28144
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int x;
  cin >> x;
  
  //process
  int k = 0;
  int current = 0;
  while(1) {
    current = current + x;
    k++;
    if(current % 360 == 0) break;
  }
  
  //output
  cout << k << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.141592653589793238462643383279502884197169399
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll r;
 cin>>r;
 ld ans=2*pi*r;
 cout <<fixed<<setprecision(20)<<ans<<"\n";
 return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,q,h,w,t,ans=0;
vl v,v1,v2;
vector<pair<pair<ll,ll>,ll>> vp1;
string s;
ll solve(){
   if(k==1)return 0;
   return n-k;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    cout<<solve()<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0);  program();}
#define int long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

#define N 3000

int n;
double p[N], dp[N][N];

double f(int h, int t) {
    int i = h+t;
    if (i == n) return (h>t?1:0);
    if(dp[h][t] != 2.0) return dp[h][t]; 
    return dp[h][t] = p[i]*f(h+1,t) + (1-p[i])*f(h,t+1);
}

void program(){
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) dp[i][j] = 2.0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>p[i];
    cout<<fixed<<setprecision(16)<<f(0,0)<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-different perspective?
-bruteforce?
-greedy?
-reduce dimensionality with problem contraints?
*/


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 1e4 + 20;
const int maxm = (int) 1e6 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
int a[maxn];
int is_prime[maxm], primes[maxm];

int get_prime()
{
    int m = 0;
    for(int i = 2; i < maxm; i++)
    {
        if(!is_prime[i])
        {
            primes[m++] = i;
            is_prime[i] = i;
        }
        for(int j = 0; j < m; j++)
        {
            if(primes[j] * i >= maxm) break;
            is_prime[i * primes[j]] = primes[j];
            if(i % primes[j] == 0) break;
        }
    }
}

int faccnt[maxm];

void work()
{
    get_prime();
    read(n);
    LL mul = 1;
    for(int i = 0; i < n; i++)
    {
        int x; read(x);
        a[i] = x;

        map<int, int> mp;
        while(x != 1)
        {
            mp[is_prime[x]]++;
            x /= is_prime[x];
        }

        auto getmax = [](int &a, int b) {a = max(a, b);};

        for(auto p : mp)
            getmax(faccnt[p.fi], p.se);
    }

    for(int i = 1; i < maxm; i++)
        if(faccnt[i])
            mul = mul * fp(i, faccnt[i], MOD) % MOD;

    LL ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans += mul * fp(a[i], MOD - 2, MOD) % MOD;
    }
    cout <<ans % MOD <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 11776
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int dp[81][330];
int a[81];

int main() {
  int T;
  cin >> T;
  while(T--) {
    int L; cin >> L;
    REP(i, L) cin >> a[i];
    memset(dp,0,sizeof(dp));
    REP(i, L-1) {
      dp[i+1][a[i]] = a[i+1];
    }
    // dp[i][j] = i-1ツ氾板姪堋つェjツづ個づつォツづ個、iツ氾板姪堋づ個値ツづ個催妥・ツ値
    for (int i=1; i<L-1; ++i) {
      for (int j=1; j<330; ++j) {
        if (dp[i][j]) {
          dp[i+1][dp[i][j]-1] = max(dp[i+1][dp[i][j]-1], j+a[i+1]);
          if (i+2<L)
            dp[i+2][j+a[i+1]] = max(dp[i+2][a[i+2]], a[i+2]);
        }
      }
    }
    // REP(i,L) {
    //   REP(j, 15) cout << dp[i][j] << " ";cout << endl;
    // }
    int ans = a[L-1];
    REP(i, 330) ans = max(ans, dp[L-1][i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

const int MOD = 1000000007;

int root[1000];
int getRoot(int v){ return root[v] == -1 ? v : root[v] = getRoot(root[v]); }

int main(){
	int H, W;
	while(cin >> H >> W){
		vector<string> vs(H);
		for(int i=0;i<H;i++) cin >> vs[i];
		long long res = 1;
		if(H%2 == 1){
			bool ok = false;
			for(int i=0;i<W/2;i++){
				if(vs[H/2][i] != vs[H/2][W-1-i]) ok = true;
			}
			if(ok) res *= 2;
		}
		if(W%2 == 1){
			bool ok = false;
			for(int i=0;i<H/2;i++){
				if(vs[i][W/2] != vs[H-1-i][W/2]) ok = true;
			}
			if(ok) res *= 2;
		}
		if(H == 1 || W == 1){
			cout << res << endl;
			continue;
		}
		memset(root, -1, sizeof(root));
		int comp = H/2 + W/2;
		for(int i=0;i<H/2;i++){
			for(int j=0;j<W/2;j++){
				vector<int> cnt(26, 0);
				const int ri = H-1-i;
				const int rj = W-1-j;
				cnt[vs[i][j]-'a']++;
				cnt[vs[i][rj]-'a']++;
				cnt[vs[ri][j]-'a']++;
				cnt[vs[ri][rj]-'a']++;
				int p = 24;
				for(int k=0;k<26;k++){
					if(cnt[k] == 2) p /= 2;
					if(cnt[k] == 3) p /= 6;
					if(cnt[k] == 4) p /= 24;
				}
				if(p == 24){
					p /= 2;
					int a = getRoot(i);
					int b = getRoot(j+500);
					if(a != b){
						--comp;
						root[b] = a;
					}
				}
				res *= p;
				res %= MOD;
			}
		}
		comp = (H/2+W/2)-comp;
		for(int i=0;i<comp;i++) res = (2*res)%MOD;
		cout << res << endl;
	}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<P> v;
ll l[100100],r[100100];

bool comp(P a, P b){
	return ((a.first==b.first)?(a.second>b.second):(a.first<b.first));
}

int main(void){
	int n,i,p,q;
	ll ans,ml=-INFLL,mr=INFLL,m=-INFLL;
	bool flag = false;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> l[i] >> r[i]; --l[i];
		m = max(m,r[i]-l[i]);
		ml = max(ml,l[i]);
		mr = min(mr,r[i]);
	}
	ans = m + max(mr-ml,0ll);
	for(i=0; i<n; ++i){
		v.push_back(P(max(r[i]-ml,0ll),max(mr-l[i],0ll)));
	}
	sort(v.begin(),v.end(),comp);
	m = INFLL;
	for(i=0; i<n; ++i){
		if(i){
			ans = max(ans,m+v[i].first);
			// cout << m+v[i].first << endl;
		}
		m = min(m,v[i].second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3956
using System;

class Program
{
  static void Main(string[] args)
  {
    Console.ReadLine();
    var cmps = Console.ReadLine().Split(' ');
    int maxHeight = int.MinValue;
    int total = 0;
    for (int i = 0; i < cmps.Length; ++i) {
      var h = int.Parse(cmps[i]);
      if (h >= maxHeight) {
        total++;
      }
      maxHeight = Math.Max(maxHeight, h);
    }
    Console.WriteLine(total);
  }
}

Measured memory_bytes: 13140
def main():
    N = int(input())
    E = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        E[a - 1].append(b - 1)
        E[b - 1].append(a - 1)
    C = [0] * N
    B = set([0])
    W = set([N - 1])
    C[0] = 1
    C[-1] = -1
    while B or W:
        BN = set()
        for b in B:
            for bb in E[b]:
                if bb != b and C[bb] == 0:
                    C[bb] = 1
                    BN.add(bb)
        B = BN
        WN = set()
        for w in W:
            for ww in E[w]:
                if ww != w and C[ww] == 0:
                    C[ww] = -1
                    WN.add(ww)
        W = WN
    return 'Fennec' if C.count(1) > C.count(-1) else 'Snuke'

print(main())


Measured memory_bytes: 23116
n,a,b = gets.split.map(&:to_i)
s = gets.chomp
P = { a: 0, b: 0 }
B = a + b
R = n.times.map do |i| 
    if s[i] == 'a' && P[:a] + P[:b] < B
        P[:a] += 1
        "Yes"
    elsif s[i] == 'b' && P[:a] + P[:b] < B && P[:b] < b
        P[:b] += 1
        "Yes"
    else
        "No"
    end
end
puts R

Measured memory_bytes: 10236
from copy import deepcopy

N = int(input())

dp = [{}] * 4

mod = int(1e9 + 7)


def ok(wxyz):
    if wxyz[1:] == "AGC" or wxyz == "AAGC" or wxyz == "ACGC" or wxyz == "AGGC" or wxyz == "ATGC" \
            or wxyz[1:] == "GAC" or wxyz[1:] == "ACG" \
            or wxyz == "AGAC" or wxyz == "AGCC" or wxyz == "AGTC" or wxyz == "AGGC":
        return 0
    else:
        return 1

# 初期化
for x in ["A", "C", "G", "T"]:
    for y in ["A", "C", "G", "T"]:
        for z in ["A", "C", "G", "T"]:
            xyz = "{}{}{}".format(x, y, z)
            dp[3][xyz] = 1 * ok("P" + xyz)


# dp
for i in range(3, N):
    dp.append({})
    for x in ["A", "C", "G", "T"]:
        for y in ["A", "C", "G", "T"]:
            for z in ["A", "C", "G", "T"]:
                xyz = "{}{}{}".format(x, y, z)
                dp[i + 1][xyz] = 0

                for w in ["A", "C", "G", "T"]:
                    wxyz = "{}{}".format(w, xyz)
                    dp[i + 1][xyz] = (dp[i + 1][xyz] + deepcopy(dp[i][wxyz[:-1]]) * ok(wxyz)) % mod

# 結果出力
print(sum(dp[N].values()) % mod)


Measured memory_bytes: 4252
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int n, k;
int data[101];

int solve(){
  int max_=0;
  for(int i=0; i<n-k+1; ++i){
    int tmp=1;
    for(int j=0; j<k; ++j) tmp*=data[i+j];
    max_=max(max_, tmp);
  }
  return max_;
}

int main(){
  while(1){
    cin >> n >> k;
    if(!n && !k) break;
    for(int i=0; i<n; ++i) cin >> data[i];
    int c1 = solve(), c2=0;
    for(int i=0; i<n; ++i){
      for(int j=i+1; j<n; ++j){
	swap(data[i],data[j]);
	c2 = max(c2, solve());
	swap(data[i],data[j]);
      }
    }
    if(c2>=c1) cout << c2-c1 << endl;
    else cout << "NO GAME" << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

vector<int> a;

int main() {
	for (int i = 0; i < 3; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end(), greater<int>());
	string aa;
	string b;
	aa = to_string(a[0]) + to_string(a[1]);
	b = to_string(a[2]);
	cout << stoi(aa) + stoi(b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<int>> matrix;
const int64_t m = 1e18;
void solve()
{

    ll n;
    cin >> n;
    int64_t a[n];
    bool zero = 0;
    fr(i, n)
    {
        cin >> a[i];
        if (a[i] == 0)
            zero = 1;
    }
    int64_t ans = 1;
    if (zero == 1)
    {
        cout << 0 << "\n";
        return;
    }
    fr(i, n)
    {
        if (a[i] > m / ans)
        {
            cout << -1 << "\n";
            return;
        }
        ans *= a[i];
    }
    cout << ans;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 4380
def main()->None:
    a, b, c, x, y = map(int, input().split())

    range_i = range(0, 100001)
    min_z = 1000000000
    for i in range_i:
        z = i * (2 * c) + (max(0, x - i) * a) + (max(0, y - i) * b)
        if z < min_z:
            min_z = z
    print(min_z)


if __name__ == "__main__":
    main()

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


int main() {
    string s; cin >> s;
    if(s == "SUN") cout << 7;
    if(s == "MON") cout << 6;
    if(s == "TUE") cout << 5;
    if(s == "WED") cout << 4;
    if(s == "THU") cout << 3;
    if(s == "FRI") cout << 2;
    if(s == "SAT") cout << 1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
*/
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define in(a) cin >> a;
using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    int m=0;
    cin >> a >> b >> c;
    cin >> m;
    int n=0;
    rep(i,1,a){
        int x = 0;
        cin >> x ;
        if((x-m)*b>c){
            n+=c;
        }else{
            n+=(x-m)*b;
        }
        m=x;
    }
    cout << n << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, x[100008], dx[100008], ans;

int main(){
	cin >> n >> m;
	
	ans = 0;
	if(m > n){
		for(ll i = 1; i <= m; i++){cin >> x[i];}
		sort(x+1, x+(m+1));
		for(ll i = 1; i <= m-1; i++){dx[i] = x[i+1]-x[i];}
		sort(dx+1, dx+m);
		for(ll i = 1; i <= m-n; i++){ans += dx[i];}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792