akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author Node2
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));       
        String str = in.readLine();
        String anser = "Yes";
        if(str.length()%2 != 0){
            anser = "No";
        }else{
            int use[] = new int[26];
            for(int i=0;i<str.length();i++){
                int moji = str.charAt(i);
                use[moji-97]++;
            }
            
            for(int a:use){
                if(a%2 != 0){
                    anser = "No";
                }
            }
        }
        
        System.out.println(anser);
    }
}

Measured memory_bytes: 8020
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = float('inf')
if(0 in x):
    K=K-1
    x.remove(0)
    if(K==0):
        print(0)
        exit()
for i in range(0,N-K+1):
    if((x[i]<0)):
        if(x[i+K-1]>0):
            ans = min(ans,abs(x[i])*2+x[i+K-1],abs(x[i])+x[i+K-1]*2)
        else:
            ans = min(ans,abs(x[i]))
    else:
            ans = min(ans,x[i+K-1])
print(ans)

Measured memory_bytes: 20084
import sys
def 解():
    N,K=[int(_) for _ in sys.stdin.readline().split()]
    aH=sorted(int(_) for _ in sys.stdin.readlines())

    iDiff = aH[-1]
    for i in range(N-K+1):
        d = aH[i+K-1] - aH[i]
        if d < iDiff:
            iDiff = d
        if iDiff == 0:
            break
    print(iDiff)
解()


Measured memory_bytes: 14244
import math

len_H, len_M, H, M = map(int, input().split())

theta_H = H * 30 + M * 0.5
theta_M = M * 6

diff = abs(theta_H - theta_M)
if diff > 180:
  diff = 360 - diff

a = len_H
b = len_M

theta = math.radians(diff)

d = (a * a) + (b * b) - (2 * a * b * math.cos(theta))

print(math.sqrt(d))

Measured memory_bytes: 9516
import sys

s = int(input())

def f(n):
    if not n%2:
        return int(n/2)
    else:
        return int(3*n+1)

a = list()
a.append(s)
i = 1
r = 0
g = 0
while 1:
    n = f(a[i-1])
    for r in a:
        if r==n:
            print(i+1)
            sys.exit()
            
            
    a.append(n)
    i=i+1

        
        

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

ll n;
ll binpow (ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return binpow (a, n-1) * a;
    else {
        ll b = binpow (a, n/2);
        return b * b;
    }
}


void calc(ll m, ll k, string &ans) {
    if (m == 0) return;
    char c = 'a';
    for (ll id = 1; id <= 26; ++id)
        if (id * binpow(26, m - 1) >= k) {
            k -= (id-1) * binpow(26, m - 1);
            c = char(id - 1 + 'a');
            break;
        }
    ans += c;
    calc(m - 1, k, ans);
}

void solve() {
    cin >> n;
    ll x = 0, t = 26, pw = 1;
    while (x + t < n) {
        x += t;
        t *= 26ll;
        ++pw;
    }
    n -= x;
    string ans = "";
    calc(pw, n, ans);
    cout << ans << "\n";
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
// abc134_c

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)n; i++)


using namespace std;


 int main(){
 int n, ans;
 cin >> n;

 vector<int> a(n), b(n);

 rep(i, n){
  cin >> a.at(i);
 }

 rep(i, n){
  b.at(i) = a.at(i);
 }

 sort(b.begin(), b.end());
 reverse(b.begin(), b.end());

 rep(i,n){
  if (b.at(0) != a.at(i)) ans = b.at(0);
  else ans = b.at(1);
  cout << ans << endl;

 }
    

 return 0;
}


//　配列のコピー!

Measured memory_bytes: 3200
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

void solve()
{
	string s;
	cin>>s;
	vector<char> ans;
	
	for(ll i=0;i<(ll)s.length();i++)
	{
	if(s[i]=='0')
	{
	ans.push_back('0');	
	}	
	else if(s[i]=='1')
	{
	ans.push_back('1');	
	}
	else
	{
	if(!ans.empty())
	{
		ans.pop_back();
	}	
	}
	}
	for(ll i=0;i<ans.size();i++)
	{
	cout<<ans[i];	
	}
	
	
    //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
return ;
}


signed main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> height(n+1,0);
    for(int i = 1;i<=n;++i)
    {
        cin>>height[i];
    }
    vector<int> dp(n+1);
    dp[1] = 0;
    dp[2] = abs(height[2] - height[1]);
    for(int i = 3;i<=n;++i)
    {
        dp[i] = min(dp[i-1] + abs(height[i] - height[i-1]),dp[i-2] + abs(height[i] - height[i-2]));
    }
    cout<<dp[n];
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

ll p = 1000000007;
ll a[ 10000 ];
ll ma[ 1000010 ];

ll pow_mod( ll, ll, ll );

int main() {
	int n;
	ll tmp = 0, g = 1, x, ans = 0;
	scanf( "%d", &n );
	for( int i = 0; i < n; ++i ) {
		scanf( "%lld", &a[ i ] );
		x = a[ i ];
		for( ll j = 2; j * j <= x; ++j ) {
			if( x % j == 0 ) {
				tmp = 0;
				while( x % j == 0 ) {
					x /= j;
					++tmp;
				}
				ma[ j ] = max( ma[ j ], tmp );
			}
		}
		if( x > 1 )
			ma[ x ] = max( ma[ x ], 1LL );
	}
	for( int i = 2; i <= 1000000; ++i ) {
		if( ma[ i ] == 0 )
			continue;
		g *= pow_mod( ( ll )i, ma[ i ], p );
		g %= p;
	}
	for( int i = 0; i < n; ++i ) {
		ans += pow_mod( a[ i ], p - 2, p );
		ans %= p;
	}
	ans *= g;
	ans %= p;
	printf( "%lld", ans );
	return 0;
}

ll pow_mod( ll x, ll y, ll p ) {
	ll res = 1;
	while( y ) {
		if( y & 1 ) {
			res *= x;
			res %= p;
		}
		x *= x;
		x %= p;
		y >>= 1;
	}
	return res;
}

Measured memory_bytes: 6656
#include <iostream>




using namespace std;

long A;
long B;
long K = 0;
bool possible = false;


int main () {

    cin >> A;
    cin >> B;

    while(K < 1000000000){
        
        if (abs(A-K) == abs(B-K)){
            possible = true;
            cout << K;
            break;
        }
        K += 1;
        
    }

    if (possible != true){      
    cout << "IMPOSSIBLE";
}
}
    

    
    


     

    

    





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

int main() {
	string s;
	cin >> s;
	for(int i = 0;i < 12;i++)
	{
		cout << s.at(i);
		if(i == 3)
		{
			cout << ' ';
		}
	}
	cout <<endl;
	return 0;
}


Measured memory_bytes: 256
/*
Problem Source : agc-032D
Author : oier_hzy
Time : Nov 24 2019
*/

/*
A : move a element to the right
B : ... left

In the best case, there're several fixed elements
We could consider all the circumstances during DP procession

f[i][j] : the first i elements (by coordinate) has been considered, and the last fixed coordinate is j
*/

#include <cstdio>
typedef long long ll;

template <typename _tp> inline void cmin(_tp&x, const _tp y) {if(x > y) x = y;}

const ll oo = 0x3f3f3f3f3f3f3f3f;
const int N = 5001;
int a[N];
ll f[N], g[N];
int n, A, B;

int main() {
	scanf("%d%d%d", &n, &A, &B);
	for(int i = 1; i <= n; ++ i) scanf("%d", a+i);
	
	for(int i = 0; i <= n; ++ i) f[i] = g[i] = +oo;
	f[0] = 0;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 0; j < a[i]; ++ j) {
			cmin(g[j], f[j] + A);
			cmin(g[a[i]], f[j]);
		}
		for(int j = a[i]; j <= n; ++ j)
			cmin(g[j], f[j] + B);
		for(int j = 0; j <= n; ++ j) f[j] = g[j], g[j] = +oo;
	}
	
	ll Ans = +oo;
	for(int i = 0; i <= n; ++ i)
		cmin(Ans, f[i]);
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
A = []
B = []
# C = []

for i in range(0, n):
    A.append(input().split())

for i in range(0, m):
    B.append(input().split())

for i in range(0, n):
    temp_A = A[i]
    # temp_C = []
    for j in range(0, l):
        temp = 0
        for k in range(0, len(temp_A)):
            temp += int(temp_A[k]) * int(B[k][j])
        if (j < l - 1):
            print(temp, end = ' ')
        else :
            print(temp)
#         temp_C.append(temp)        
#     C.append(temp_C)

# for i in range(0, n):
#     for j in range(0, l):
#         if (j < l - 1):
#             print(C[i][j], end = ' ')
#         else :
#             print(C[i][j])


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

#define rep(i,b,e) for(auto i=b;i<e;i++)

typedef long long ll;

int main(){
	int n;
	cin>>n;
	
	int a[n][n];
	rep(i,0,n) 
		rep(j,0,n)
			cin>>a[i][j];
		
	vector <ll> dp(1<<n,0);
	
	rep(group,0,(1<<n))
		rep(i,0,n)
			if(group&(1<<i))
				rep(j,i+1,n)
					if(group&(1<<j))
						dp[group]+=a[i][j];
	//O(2ⁿn²)
						
	rep(mask,0,(1<<n))
		for(int submask=mask;submask;submask=(submask-1)&mask)
			dp[mask]=max(dp[mask],dp[submask]+dp[submask^mask]);
	// O(Σ2ᵏ*ⁿCₖ) = O(3ⁿ)

	cout<<dp[(1<<n)-1]<<endl;
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,ans,a[N],b[N],c[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
struct node{
	int val,id;
};
bool cmp(node a,node b)
{
	return a.val>b.val;
}
signed main()
{
	n=read();
	for(int i=1;i<n;i++)a[i]=read();
	for(int i=1;i<n;i++)b[i]=b[i+1]=a[i];
	for(int i=1;i<n;i++)
	{
		b[i]=min(b[i],a[i]);
		b[i+1]=min(b[i+1],a[i]);
	}
	for(int i=1;i<=n;i++)ans+=b[i];
	cout<<ans;
}

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

int main(){
  int n;

  while((cin>>n)&&(n!=0)){
    int count=0;
    int c=1;
    while(c!=n/2+1){
      int sum=0;
      for(int i=c;i<=n;i++){
        sum += i;
        if(sum==n) count++;
      }
      c++;
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
 
int main()
{
    int n;
    while(cin>>n)
    {
        int a[2*n];
        int i;
        for(i=0;i<2*n;i++)
            cin>>a[i];
        sort(a,a+2*n);
        int sum=0;
        for(i=0;i<2*n;i+=2)
        {
            sum+=a[i];
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

struct Item{
  int value,weight;
};

int dp[10005];

Item item[105];

signed main(){
  int n,w;
  cin>>n>>w;
  
  for(int i=0; i<n; i++) cin>>item[i].value>>item[i].weight;
  
  for(int i=0; i<n; i++){
    for(int j=0; j+item[i].weight<=w; j++){
      dp[j+item[i].weight]=max(dp[j+item[i].weight], dp[j]+item[i].value);
    }
  }
  
  cout<<dp[w]<<en;
}




Measured memory_bytes: 3128
r, c = STDIN.gets.split(' ').map(&:to_i)
csum = Array.new(c, 0)
r.times do |i|
  ary = STDIN.gets.split(' ').map(&:to_i)
  c.times do |j|
    csum[j] += ary[j]
  end
  ary << ary.reduce{|sum, n| sum + n}
  puts ary.join(' ')
end
csum << csum.reduce{|sum, n| sum + n}
puts csum.join(' ')

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;  cin >> a >> b >> c;
    bool ans;
    map<int, int> mp;
    for (int i = 0; ; ++i) {
      int mo = i * a % b;
      if (mp[mo] > 0) {
        ans = false;
        break;
      }
      mp[mo]++;
      if (mo == c) {
        ans = true;
        break;
      }
    }
    if (ans) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }

    return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,x,t;
    cin >> n >> x >> t;
    int ans = (n / x) * t + (n % x > 0? t : 0);
    cout << ans << endl;
}


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

std::vector<long long> common_divisors(long long a, long long b) {
	if (a > b) std::swap(a, b);
	std::vector<long long> ret(0), st(0);
	for (int i = 1; i <= a / i; i++) {
		if (a % i == 0) {
			if (b % i == 0) ret.push_back(i);
			if (b % (a / i) == 0 && i < a / i) st.push_back(a / i);
		}
	}
	while (st.size()) {
		ret.push_back(st.back());
		st.pop_back();
	}
	return ret;
}

bool is_prime(long long n) {
	if (n < 2) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	for (int i = 3; i <= n / i; i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	long long a, b;
	std::cin >> a >> b;
	std::vector<long long> v = common_divisors(a, b);
	long long ans = 1;
	for (auto i : v) {
		if (is_prime(i)) ans++;
	}
	std::cout << ans << '\n';
 
	return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if ((A + B) % 2 == 0){
			System.out.println((A+B)/2);
		} else {
			System.out.println("IMPOSSIBLE");
		}


	}


}

Measured memory_bytes: 22356
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		if (e - a > k) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,m;
	cin>>n>>m;
	vector<lp> d(n);
	rep(i,n)cin>>d[i].first>>d[i].second;
	sort(all(d));
	ll ans = 0;
	rep(i,n){
		if(d[i].second<m){
			ans += d[i].second*d[i].first;
			m -= d[i].second;
			continue;
		}
		ans += m*d[i].first;
		break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  int wa,sa,seki;
  wa=a+b;
  sa=a-b;
  seki=a*b;
  int m;
  m = max(wa,sa);
  m = max(m, seki);
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    vector<int> retu(100006,0);
    vector<int> B(2);
    for(int i = 0;i<N;i++) {
        int A;cin >> A;
        if(i <= 1) B.at(i) = A;
        retu.at(A)++;
    }
    int ans = 0;

    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N == 2){
        if(abs(B.at(1)-B.at(0)) <= 2){
            cout << 2 << endl;
        }
        else {
            cout << 1 << endl;
        }
        return 0;
    }

    for(int i = 0;i<N-2;i++){
        ans = max(ans,retu.at(i)+retu.at(i+1)+retu.at(i+2));
    }

    cout << ans << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 640
from itertools import product
from collections import deque

def zero_one_bfs(E, s, init=0):
    N = len(E)
    order = [-1] * N # a bfs ordering of each vertex
    dist = [-1] * N # the distance of each vertex from s
    dq = deque([(s, init)]) # (vertex, dist)
    num = 0 # current ordering
    while dq:
        v, d = dq.popleft()
        if order[v] < 0: # visited v for the first time
            order[v] = num; dist[v] = d
            num += 1
            for u, w in E[v]:
                if order[u] >= 0: continue
                if w == 0: dq.appendleft((u, d))
                else: dq.append((u, d+1))
    return order, dist

H, W = map(int, input().split())

def vtx(i, j): return i*W + j
def coord(n): return divmod(n, W)

grid = [input() for _ in range(H)] # |string| = W
E = [[] for _ in range(H * W)]
for i, j in product(range(H), range(W)):
    v = vtx(i, j)
    check = [vtx(i+dx, j+dy) for dx, dy in [(1, 0), (0, 1)] if i+dx <= H-1 and j+dy <= W-1]
    for u in check:
        x, y = coord(u)
        if grid[i][j] == '.' and grid[x][y] == '#':
            E[v].append((u, 1))
        elif grid[i][j] == '#' and grid[x][y] == '.':
            E[v].append((u, 0))
        else:
            E[v].append((u, 0))
_, dist = zero_one_bfs(E, 0, 0 if grid[0][0] == '.' else 1)
print(dist[vtx(H-1, W-1)])

Measured memory_bytes: 6900
# include "cstdio"
# define max(a,b) ((a)>(b)?(a):(b)) 

int main(){
    int a,b,ans;
    scanf("%d%d",&a,&b);  
    ans=max(a+b,max(a-b,a*b)); 
    printf("%d",ans);   
    return 0; 
} 

Measured memory_bytes: 128
s = input()
first = int(s[:2])
second = int(s[2:])
if 1 <=first <= 12 and 1 <= second <= 12:
    print("AMBIGUOUS")
elif 1 <= first <= 12:
    print("MMYY")
elif 1 <= second <= 12:
    print("YYMM")
else:
    print("NA")

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

using namespace std ;
int main()
{
  int num,temp,cost1,cost2 ;
  long long dp1, dp2, cost_final ;
  cin>>num ;
  vector<int> cost ;
  vector<long long> dp ;
  cost.clear() ;
  dp.clear() ;
  for(int i=0;i<num;i++)
  {
    cin>>temp ;
    cost.push_back(temp) ;
  }
  dp.push_back(0) ;
  dp.push_back(abs(cost.at(0)-cost.at(1))) ;
  for(int i=2;i<num;i++)
  {
    cost1=abs(cost.at(i)-cost.at(i-1)) ;
    cost2=abs(cost.at(i)-cost.at(i-2)) ;
    dp1=cost1+dp.at(i-1) ;
    dp2=cost2+dp.at(i-2) ;
    cost_final=min(dp1,dp2) ;
    dp.push_back(cost_final) ;
  }
  cout<<dp.at(num-1)<<endl ;
                 
}


Measured memory_bytes: 1784
n, m = map(int, input().split())
a = list(map(int, input().split()))

num1 = a[0]
num2 = 0
while num1 % 2 == 0:
    num1 //= 2
    num2 += 1
gc = 2 ** num2

b = []
for i in a:
    if i % gc != 0 or (i // gc) % 2 == 0:
        print(0)
        exit()
    else:
        b.append(i // gc)

from fractions import gcd
lcm = 1
for i in b:
    lcm = (lcm * i) // gcd(lcm, i)

ans = m // (lcm * (gc // 2))
ans = (ans + 1) // 2
print(ans)

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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  vector<int64_t> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    int64_t tmp;
    cin >> tmp;
    a[i] = a[i - 1] + tmp;
  }

  uint64_t ans = ~0LLU;
  int left_cut = 1, right_cut = 3;
  for (int i = 2; i < n - 1; ++i) {
    while (left_cut < i - 1 &&
           abs(a[i] - 2 * a[left_cut + 1]) <= abs(a[i] - 2 * a[left_cut]))
      ++left_cut;
    while (right_cut < n - 1 && abs(a[n] - 2 * a[right_cut + 1] + a[i]) <=
                                    abs(a[n] - 2 * a[right_cut] + a[i]))
      ++right_cut;
    int64_t sums[] = {a[left_cut], a[i] - a[left_cut], a[right_cut] - a[i],
                  a[n] - a[right_cut]};
    // cout << left_cut << " " << right_cut << "\n";
    uint64_t score =
        *max_element(sums, sums + 4) - *min_element(sums, sums + 4);
    ans = min(ans, score);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 1200
int main(){
	int i,cnt[26]={};
	char ss;
	while(scanf("%c", &ss) != EOF){
		for(i=0; i<26; i++){
			if(ss=='a'+i || ss=='A'+i){cnt[i]++;}	
		}
	}
	for(i=0; i<26; i++){
		printf("%c : %d\n", 'a'+i,cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include <vector>
#include <cassert>

//Monoid
// value_t
// op
// id

template<typename Monoid>
class SegmentTree{
  public:
  using value_t=typename Monoid::value_t;
  using size_t=std::size_t;

  private:
  size_t n,n0;
  std::vector<value_t> dat;

  public:
  SegmentTree(size_t n_):n(n_){
    assert(n_>0);
    n0=1;
    while(n0<n)n0<<=1;
    dat=std::vector<value_t>(2*n0-1,Monoid::id);
  }

  SegmentTree(const std::vector<value_t>& tmp):n(tmp.size()){
    assert(n>0);
    n0=1;
    while(n0<n)n0<<=1;
    dat=std::vector<value_t>(2*n0-1,Monoid::id);
    for(long long i=0;i<n;i++)dat[i+n0-1]=tmp[i];
    for(long long i=n0-2;i>=0;i--)dat[i]=Monoid::op(dat[2*i+1],dat[2*i+2]);
  }

  void update(size_t i,value_t val,bool change){
    assert(0<=i&&i<n);
    std::size_t now=i+n0-1;
    if(change)dat[now]=val;
    else dat[now]=Monoid::op(dat[now],val);

    while(now>0){
      now=(now-1)>>1;
      dat[now]=Monoid::op(dat[2*now+1],dat[2*now+2]);
    }
  }

  value_t fold(size_t a,size_t b){
    assert(0<=a&&a<=b&&b<=n);
    value_t rval=Monoid::id,lval=Monoid::id;
    size_t l=a+n0-1,r=b+n0-1;
    for(;l<r;l>>=1,r>>=1){
      if(!(r&1)){
        r--;
        rval=Monoid::op(dat[r],rval);
      }
      if(!(l&1)){
        lval=Monoid::op(lval,dat[l]);
        l++;
      }
    }

    return Monoid::op(lval,rval);
  }
};

struct Monoid{
  using value_t=long long;
  static constexpr value_t id=0;
  static constexpr value_t op(value_t a,value_t b){
    return a|b;
  }
};

#include <string>
#include <iostream>

using ll=long long;

int main(){
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  ll n;
  std::cin>>n;
  std::string s;
  std::cin>>s;
  
  std::vector<ll> tmp(n);
  for(ll i=0;i<n;i++)tmp[i]=(1ll<<(s[i]-'a'));
  
  SegmentTree<Monoid> seg(tmp);
  
  ll q;
  std::cin>>q;
  
  for(ll i=0;i<q;i++){
    ll mode;
    std::cin>>mode;
    if(mode==1){
      ll a;
      char c;
      std::cin>>a>>c;
      seg.update(a-1,1ll<<(c-'a'),true);
    }else{
      ll l,r;
      std::cin>>l>>r;
      ll val=seg.fold(l-1,r);
      ll cnt=0;
      for(ll j=0;j<26;j++)if((val>>j)&1)cnt++;
      std::cout<<cnt<<"\n";
    }
  }
}


Measured memory_bytes: 13084
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans[ohara], a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp, mp2;

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

  cin >> n >> k;
  rep(i, n) cin >> a[i], a[i]--;
  ll now = 0;
  while (1) {
    mp[now] = 1;
    cnt++;
    now = a[now];
    k--;
    if (mp[now]) break;
    if (k == 0) {
      Cout(now + 1);
      return 0;
    }
  }
  // debug(k);
  ll syu_st = now, syu_len = 0;
  ans[0] = syu_st;
  cnt = 0;
  while (1) {
    mp2[now] = 1;
    now = a[now];
    cnt++;
    ans[cnt] = now;
    if (mp2[now]) break;
  }
  k %= cnt;
  Cout(ans[k] + 1);
  return 0;
}


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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long

int main(int argc, char const *argv[]){
	int flag;
	char a[107],b[107];
	scanf("%s %s",&a,&b);
	flag = strcmp(a,b);
	if(strlen(a) == strlen(b)){
		if(flag == 0)	puts("EQUAL");
		else if(flag > 0)	puts("GREATER");
		else puts("LESS");
	}	
	else if(strlen(a) > strlen(b))	puts("GREATER");
	else puts("LESS");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = -INT_MIN, minv; cin >> minv;
  for (int i = 1; i < n; ++i) {
    int a;
    cin >> a;
    ans = max(ans, a - minv);
    minv = min(minv, a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N, W = [int(item) for item in input().split()]
    item = np.array([[int(item) for item in input().split()] for _ in range(N)])


    dp = np.full(10**5 + 1, 10**12+1)
    dp[0] = 0

    for i in range(N):
        w, v = item[i]
        np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

    print(np.where(dp <= W)[0][-1])

if __name__ == "__main__":
    main()

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

int main() {
  int A, B, C; cin >> A >> B >> C;
  if (A == B && A != C) cout << "Yes" << endl;
  else if (B == C && B != A) cout << "Yes" << endl;
  else if (C == A && C != B) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

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

  vector<int> start;
  REP(i, N) {
    if((i == 0) || (S[i] != S[i - 1])) {
      start.push_back(i);
    }
  }
  start.push_back(N);
  int M = start.size();

  int ret = 0;
  REP(i, M - 1) {
    int tmp;
    if(S[start[i]] == '0') {
      tmp = start[min(M - 1, i + 2 * K)] - start[i];
    }else{
      tmp = start[min(M - 1, i + 2 * K + 1)] - start[i];
    }
    ret = max(ret, tmp);
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int r,g,b,times;
	cin >> r >> g >> b >> times;
	int cnt = 0;
	while(g<=r){
		g*=2;
		cnt++;
	}
	while(b<=g){
		b*=2;
		cnt++;
	}
	if(cnt<=times) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 3228
import java.util.*;
import java.util.function.ToDoubleFunction;


public class Main {
    private static final String ex = "abcb\n" +
            "aacb\n" +
            "bccc";

    public static void main(String[] args) {
        solve(new Scanner(System.in));
//        solve(new Scanner(ex));
    }

    private static void solve(Scanner scanner) {
        LinkedList<Character> A = new LinkedList();
        for (char c: scanner.nextLine().toCharArray()) A.add(c);
        LinkedList<Character> B = new LinkedList();
        for (char c: scanner.nextLine().toCharArray()) B.add(c);
        LinkedList<Character> C = new LinkedList();
        for (char c: scanner.nextLine().toCharArray()) C.add(c);

        LinkedList<Character> player = A;

        while (true) {
            Character top = player.poll();
            if (top == 'a') player = A;
            else if (top == 'b') player = B;
            else if (top == 'c') player = C;

            if (player.size() == 0) {
                System.out.println(Character.toUpperCase(top));
                break;
            }
        }
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cstdio>
#include <cmath>
#include <deque>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int m, n;
	cin >> n >> m;
	int ans = 0;
	ans += ((ll)1900 * m + 100 * (n - m)) * pow(2, m);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
/*template created by */
#include <bits/stdc++.h>
#define SI set<int>
#define VI vector<int>
#define ull unsigned long long
#define inint(a) scanf("%d",&a)
#define input(a) cin>>a
#define ll long long
#define f first
#define s second
#define len(s) s.length()
#define FOR(i, a, b) for(i = a ; i < b ; i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    bool res = (!(a % 3)) || (!(b % 3)) || (!((a + b) % 3));
    if(res){
        cout << "Possible\n";
    }
    else {
        cout << "Impossible\n";
    }
    return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    auto a = s[0 .. 2].to!(long);
    auto b = s[2 .. 4].to!(long);
    if(a <= 12 && b <= 12)
    {
        if(a == 0 && b == 0)
        {
			writeln("NA");
        }
        else if(a == 0)
        {
            writeln("YYMM");
        }
        else if(b == 0)
        {
            writeln("MMYY");
        }
        else
        {
            writeln("AMBIGUOUS");
        }
    }
    else if(a > 12)
    {
        if(b == 0 || b > 12)
        {
            writeln("NA");
        }
        else
        {
            writeln("YYMM");
        }
    }
    else
    {
        if(a == 0 || a > 12)
        {
            writeln("NA");
        }
        else
        {
            writeln("MMYY");
        }
    }
}


Measured memory_bytes: 256
from collections import deque,defaultdict
import sys
input = sys.stdin.readline

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

edge_dic = defaultdict(lambda: [])

for _ in range(N-1):
    a,b = map(int,input().split())
    edge_dic[a-1].append(b-1)
    edge_dic[b-1].append(a-1)

ans_array = [0] * N

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


node_deque = deque()
used_array = [-1] * N
node_deque.append(0)
used_array[0] = 1

while len(node_deque):
    node = node_deque.popleft()
    for n in edge_dic[node]:
        if used_array[n] == 1:
            continue
        ans_array[n] += ans_array[node]
        used_array[n] = 1
        node_deque.append(n)

ans_str = map(str,ans_array)
print(" ".join(ans_str))

Measured memory_bytes: 131140
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << "\n";
}


Measured memory_bytes: 256
n = gets.to_i
min = last = gets.to_i
max = 0
profits = []
(n-1).times{
  current = gets.to_i
  catch(:next) do
    if (current <= min)
      profits<<(current-last) if (profits.bsearch{|i| i >= 0} == nil)
      min = current
      throw :next
    end
    max = current if (current > last)
    profits<<(max-min)
  end
  last = current
}
puts profits.max

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

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
const int WHITE = 0, BLACK = 1;

int n;
vector<int> vs[N];
int memo[2][N];

int mult(ll a, ll b) {
    return (a * b) % mod;
}

int dp(int node, int par_color, int par=-1) {
    int &ans = memo[par_color][node];
    if(ans != -1) return ans;
    int white = 1, black = (par_color != BLACK);
    for(int x : vs[node]) if(x != par) {
        white = mult(white, dp(x, WHITE, node));
        black = mult(black, dp(x, BLACK, node));
    }
    ans = white + black;
    ans %= mod;
    return ans;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        vs[u].push_back(v);
        vs[v].push_back(u);
    }
    memset(memo, -1, sizeof(memo));
    cout << dp(0, WHITE) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

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

#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

typedef long long ll;

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str)
{
    int num;
    std::istringstream iss(str); //put string in input stream
    iss >> num; return num; //read from stream as integer
}
ll  OO = 10e9;

const int MAXN = 10;
int X[MAXN];
int Y[MAXN];
double dist[MAXN][MAXN];
int path[MAXN];
double tot = 0;
int cnt = 0;
int main() {
    IOS();

    int n;
    cin >> n ;
    REP(i,n)
    {
        cin>>X[i]>>Y[i];
        path[i] = i;
    }
    //calculate distance between each 2
    for(int i = 0 ; i < n ; ++i)
    {
        for(int j = 0 ; j < n ;++j)
        {
            if(i == j) continue;
            double tempX = (X[i]-X[j]);
            double tempY = (Y[i]-Y[j]);
            dist[i][j]  = sqrt( tempX*tempX + tempY*tempY);
        }
    }
    //for each possiblities
    do {
        for(int i = 1 ; i < n ; ++i)
        {
            tot += dist[path[i]][path[i-1]];
        }
        cnt++;
    } while ( next_permutation(path,path+n) );

    cout<<std::setprecision(12) <<tot/cnt<<endl;
    return 0;
}



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

int main() {
    int A, B;
    cin >> A >> B;

    int cnt=0;

    for(int i = A; i <= B; i++){
        if((i/10000 == i%10)&&(i/1000%10)==(i/10%10)){
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c ;
	cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;
 
	}
	else if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
	}
	else if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
 
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (unsigned long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define llinf LLONG_MAX/3
#define LLINF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SCD second

using namespace std;

signed main()
{
	string S;
	bool n = false, s = false, e = false, w = false;
	cin >> S;
	FOR(i, 0, S.length()) {
		if (S[i] == 'N') {
			n = true;
		}
		if (S[i] == 'S') {
			s = true;
		}
		if (S[i] == 'W') {
			w = true;
		}
		if (S[i] == 'E') {
			e = true;
		}
	}
	bool house = (n == s) && (e == w);
	cout << (house ? "Yes" : "No");
	return 0;
}



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

int main()
{
	int i,x,y,flag=0;
	cin>>x>>y;
	if(y%2==1) cout<<"No\n";
	else
	{
		for(int j=0
		;j<=x;j++)
		{
			if(4*j+2*(x-j)==y)
			{
				flag=1;
				break;
			}
		}
		if(flag) cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll t[n+1]={},a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  bool conf[n+1];
  for(int i=0;i<n;i++) conf[i]=false;

  ll ht[n+1]={},ha[n+1]={};
  conf[0]=true;
  //conf[n-1]=true;
  ht[0]=t[0];
  //ha[n-1]=a[n-1];

  for(int i=1;i<n;i++){
    if(t[i]>t[i-1]){
      conf[i]=true;
    }
    ht[i]=t[i];
  }

  bool flag=false;
  for(int i=n-1;i>=0;i--){
    ha[i]=a[i];
    if(a[i]>a[i+1]){
      if(conf[i]){
        if(ht[i]!=ha[i]) flag=true;
      }else{
        conf[i]=true;
        if(ha[i]>ht[i]) flag=true;
      }
    }
  }

  if(flag) cout<<0<<endl;
  else{
    ll ans=1;
    for(int i=0;i<n;i++){
      ll mi=min(ha[i],ht[i]);
      ll ma=max(ha[i],ht[i]);
      if(conf[i]) continue;
      ans=ans*(mi)%MOD;
    }
    cout<<ans<<endl;
  }

  return 0;
}


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

int main(){
	int i, j, k ,n,m,l,f;
	string s;
	double a,b;
	cin >> a >> b;
	cout << a/b << endl;
}

Measured memory_bytes: 256
import heapq
N, M = list(map(int,input().split()))
h = []
for x in input().split():
  heapq.heappush(h, -int(x))
for i in range(M):
  x = -heapq.heappop(h)
  x //= 2
  heapq.heappush(h,-x)
print(-sum(h))

Measured memory_bytes: 14180
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  const int64_t INF = 1'000'000'000L * 200'000 + 1;
  vector<vector<int64_t>> dp(N + 2, vector<int64_t>(3, -INF));
  dp[0][0] = 0;
  rep(i, N) {
    int a;
    cin >> a;
    irep(j, 2) {
      dp[i + 2][j] = dp[i][j] + a;
      rep(k, j) {
        if (i - (j - k) >= 0) {
          dp[i + 2][j] = max(dp[i + 2][j], dp[i - (j - k)][k] + a);
        }
      }
      dp[i + 2][j] = max(dp[i + 2][j], -INF);
    }
  }

  /*rep(i, N + 2) {
    rep(j, 3) { cerr << " " << dp[i][j]; }
    cerr << "\n";
  }*/

  if (N % 2 == 0) {
    cout << max(dp[N + 1][1], dp[N][0]) << endl;
  } else {
    cout << max(dp[N + 1][2], max(dp[N][1], dp[N - 1][0])) << endl;
  }
  return 0;
}

Measured memory_bytes: 14280
n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

count=[0]*(10**5+1)
for i in range(n):
    count[ab[i][0]]+=ab[i][1]

tmp=0
for i in range(len(count)):
    tmp+=count[i]
    if tmp>=k:
        print(i)
        quit()

Measured memory_bytes: 30160
n = int(input())
index=0
minL=[]
moneyL=[]
while index < n:
    inputN = int(input())
    moneyL.append(inputN)
    if index==0:
        minL.append(inputN)
    else:
        if minL[index-1] < inputN:
            minL.append(minL[index-1])
        else:
            minL.append(inputN)
    index+=1

index2=1
maxProfit = -10**9
while index2 < len(moneyL):
    if moneyL[index2] - minL[index2-1] > maxProfit:
        maxProfit = moneyL[index2] - minL[index2-1]
    else:
        pass
    index2+=1

print(maxProfit)


Measured memory_bytes: 15156
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
ch_cnt = 0
b = []
for i in range(n):
    if a[i] >= 3200:
        ch_cnt += 1
        b.append('special')
    elif a[i] < 3200 and a[i] >= 2800:
        b.append('red')
    elif a[i] < 2800 and a[i] >= 2400:
        b.append('orange')
    elif a[i] < 2400 and a[i] >= 2000:
        b.append('yellow')
    elif a[i] < 2000 and a[i] >= 1600:
        b.append('blue')
    elif a[i] < 1600 and a[i] >= 1200:
        b.append('cyan')
    elif a[i] < 1200 and a[i] >= 800:
        b.append('green')
    elif a[i] < 800 and a[i] > 400:
        b.append('brown')
    else:
        b.append('gray')
b_cnt = Counter(b)
spe_cnt = 0
if b_cnt['special']:
    spe_cnt += b_cnt['special']
    if len(b_cnt) == 1:
        print(1, min(8, spe_cnt))
    else:
        print(len(b_cnt)-1, len(b_cnt)-1+spe_cnt)
else:
    print(len(b_cnt), len(b_cnt))

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

long mod=1e9+7;


int main() {
  int n,a,b;cin>>n>>a>>b;
  int y=0;
  int kaigai=0;
  rep(i,n){
    char c;cin>>c;
    if(c=='b'){
      kaigai++;
      if(y<a+b&&kaigai<=b)y++,cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
    if(c=='c')cout<<"No"<<endl;
    if(c=='a'){
      if(y<a+b)y++,cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  }
}



Measured memory_bytes: 640