akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.IntStream;

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

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String S) {
        return IntStream.range(0, S.length() - 1).anyMatch(i -> S.charAt(i) == S.charAt(i + 1)) ? "Bad" : "Good";
    }
}

Measured memory_bytes: 35960
#include<stdio.h>
#include<math.h>
#define PI 3.1415926535
int main(void)
{
    int a,b,c;
    double S,L,h;
    scanf("%d %d %d",&a,&b,&c);
    S=0.5*a*b*sin(c*PI/180);
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(c*PI/180));
    h=(2*S)/a;
    printf("%f\n",S);
    printf("%f\n",L);
    printf("%f\n",h);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#define endl '\n'

using namespace std;

bool visited[101];
int ret;
int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    while(N--)
    {
        int d; cin >> d;
        if(!visited[d])
        {
            visited[d] = true;
            ret += 1;
        }
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 1000000007;

int modPow(int a, int p){
    if(p == 0) return 1;
    long long res = modPow(a, p/2);
    res = (res * res)%MOD;
    if(p%2) res = (res * a)%MOD;
    return res;
}

int main(){
    int N;
    while(cin >> N){
        string S; cin >> S;
        vector<int> dp(N+1, 0);
        dp[0] = 1;
        for(int i=0;i<N;i++){
            vector<int> next(N+1, 0);
            for(int j=0;j<=N;j++){
                if(j < N){
                    next[j+1] += 2 * dp[j];
                    next[j+1] %= MOD;
                }
                next[max(0, j-1)] += dp[j];
                next[max(0, j-1)] %= MOD;
            }
            dp = next;
        }
        long long res = dp[S.size()];
        res *= modPow(modPow(2, S.size()), MOD-2);
        res %= MOD;
        cout << res << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(n*a < b) {
			System.out.println(n*a);
		}else if(n*a >= b) {
			System.out.println(b);
		}
	}

}

Measured memory_bytes: 20692
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), r(n);
    FOR(i, n)cin >> a[i];
    r[0] = a[0];
    FOR1(i, n)r[i] = r[i - 1] + a[i];
    map<ll, ll> M;
    FOR(i, n)M[r[i] % m]++;
    ll ans = 0;
    for (auto b : M)ans += b.second * (b.second - 1) / 2;
    ans += M[0];
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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 input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end());
    map<ll,ll> mp;
    rep(i,m) {
        ll b,c; cin>>b>>c;
        mp[c] += b;
    }
    ll ans = 0;
    rep(i,n) {
        if (mp.empty()) {
            ans+=a[i];
            continue;
        }
        auto itr = prev(mp.end());
        itr->second--;
        if (itr->first>a[i]) ans+=itr->first;
        else ans += a[i];
        if (itr->second<=0) mp.erase(itr);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        mp[k]++;
        
    }
    vector<int > v;
    for(auto x: mp){
        v.push_back(x.first);
    }
    cout<<v.size();
    return 0;
    
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
N=int(input())
towns = list(list(map(int,input().split())) for _ in range(N))

distance_sum = 0
for i in range(N):
    for j in range(i):
        distance_sum += math.sqrt((towns[i][0]-towns[j][0])**2+(towns[i][1]-towns[j][1])**2)

print(2*distance_sum/N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,W;cin >> H >> W;
  rep(i,W+2) cout << "#";
  cout << endl;
  rep(i,H){
    cout << "#";
    rep(i,W){
      char x;cin >> x;cout << x;
    }
    cout << "#" << endl;
  }
  rep(i,W+2) cout << "#";
  cout << endl;
  return 0;
}


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

        
    
int main(){
  int n, k; cin >> n >> k; int l[k], r[k]; ll cum[202020] = {}; ll dp[202020] = {};
  rep(i, k){
    int a, b; cin >> a >> b; l[i] = a; r[i] = b;
  }
  dp[0] = 1; cum[1] = 1;
  for(int i=1; i<=n; i++){
    rep(j, k){
      if(i-r[j]>=0){
        dp[i]+=(cum[i-l[j]+1]-cum[i-r[j]]+mod)%mod; dp[i]%=mod;
      }
      else if(i-l[j]>=0){
        dp[i]+=(cum[i-l[j]+1]%mod); dp[i]%=mod;
      }
      else continue;
    }
    cum[i+1] = (dp[i]+cum[i])%mod;
  }
  cout << dp[n-1] << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void solve(){
	cin >> n;
	
	i64 ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				ans += __gcd(i,__gcd(j,k));
			}
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3636
// C++ program to print all primes smaller than or equal to 
// n using Sieve of Eratosthenes 
#include <bits/stdc++.h> 
using namespace std; 

void SieveOfEratosthenes(int n, int x) 
{ 
	// Create a boolean array "prime[0..n]" and initialize 
	// all entries it as true. A value in prime[i] will 
	// finally be false if i is Not a prime, else true. 
	bool prime[n+1]; 
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		// If prime[p] is not changed, then it is a prime 
		if (prime[p] == true) 
		{ 
			// Update all multiples of p greater than or 
			// equal to the square of it 
			// numbers which are multiple of p and are 
			// less than p^2 are already been marked. 
			for (int i=p*p; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	// Print all prime numbers 
	for(int i = x; i < 200200; i++){
		if(prime[i]) { cout<<i<<"\n"; return; }
	}
} 

// Driver Program to test above function 
int main() 
{ 
	int x; cin>>x;
	SieveOfEratosthenes(200200,x); 
	return 0; 
} 


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int c[] = new int[26];
        for(int i = 0;i<s.length();i++){
            int kari = s.charAt(i) - 'a';
            c[kari] = 1;
        }
        for(int i = 0;i<26;i++){
            if(c[i] == 0){
                System.out.println((char)('a' + i));
                return;
            }
        }
        System.out.println("None");
        sc.close();
    }
}

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

using ll=long long; 

int pow(int a,int b){
	int ret=1;
	while(b>0){
		b--;
		ret*=a;
	}
	return ret;
}

void solve(){
	int x;
	cin>>x;
	int maxv=-1;
	for(int i=1; i<33; i++){
		for(int j=2; j<11; j++){
			int a=pow(i,j);
			if(a>x)break;
			maxv=max(maxv, a);
		}
	}
	cout<<maxv<<endl;
}

signed main(){
	//while(1)
	solve();
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  vector<int> a(3), b(3), c(9);
  bool f = true;
  a[0] = 0;
  int t;
  for(int i=0;i<3;i++){
    cin>>t;
    b[i]=t;
  }
  cin>>t;
  a[1]=t-b[0];
  for(int i=1;i<3;i++){
    cin>>t;
    if(t-b[i]!=a[1])f=false;
  }
  cin>>t;
  a[2]=t-b[0];
  for(int i=1;i<3;i++){
    cin>>t;
    if(t-b[i]!=a[2])f=false;
  }

  if(f){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fn(i,n) for(int i=0;i<n;i++)
#define rn(i,n )for(int i=1;i<n;i++)
#define ll  long long int
#define wh while
#define str string
#define pb push_back
#define N 210100
#define MOD 100000007
#define sc(n) scanf("%lld",&n)
#define mkp(a,b) make_pair(a,b)
#define INF 100000000000
using namespace std;
ll v[N]={0};
ll power(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p; 
    while (y > 0)
    {
     
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;  
    }
    return res;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n,k;cin>>n>>k;
    rn(i,n+1)
    v[i%k]++;
    
    if(k%2==1)
    {
        cout<<v[0]*v[0]*v[0]<<endl;
    }
    else
    {
        cout<<v[k/2]*v[k/2]*v[k/2] + v[0]*v[0]*v[0]<<endl;
    }
    
    
  
   return 0;
}

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

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    sort(a.begin(), a.end());
    if(!a[0]){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i, n){
        if(a[i] <= 1000000000000000000/ans){
            ans *= a[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3996
<?php
// Your code here!
// $s = trim(fgets(STDIN));
fscanf(STDIN, "%d %d %d", $n,$a,$b);

$sum = $a + $b;
$syou = intval($n / $sum);
$amari = $n % $sum;

$ans = $syou * $a;

if($amari > 0){
    $ans += (min($amari, $a));
}

echo $ans;

?>

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

const int MAX_N = 50005;

int n, m;
int a[85][85];
int b[85][85];
bool dp[85][85][6405];

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

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> b[i][j];
        }
    }

    int tmp = abs(a[0][0] - b[0][0]);
    dp[0][0][tmp] = true;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < 6400; k++) {
                if (dp[i][j][k]) {
                    int k1 = abs(k + a[i+1][j] - b[i+1][j]);
                    if (k1 < 6400) dp[i+1][j][k1] = true;
                    int k2 = abs(k - a[i+1][j] + b[i+1][j]);
                    if (k2 < 6400) dp[i+1][j][k2] = true;
                }
                if (dp[i][j][k]) {
                    int k1 = abs(k + a[i][j+1] - b[i][j+1]);
                    if (k1 < 6400) dp[i][j+1][k1] = true;
                    int k2 = abs(k - a[i][j+1] + b[i][j+1]);
                    if (k2 < 6400) dp[i][j+1][k2] = true;
                }
            }
        }
    }

    int ans;
    for (int i = 0; i < 6400; i++) {
        if (dp[n-1][m-1][i]) {
            ans = i;
            break;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 45184
n=int(input())
m=n-1
c=2 if n>2 else 1
for i in range(2,int(m**.5)+1):
	if m%i==0:
		c+=1
		if m//i!=i:
			c+=1
for i in range(2,int(n**.5)+1):
	if n%i==0:
		j=n//i
		while j%i==0:
			j//=i
		if j%i<=1:
			c+=1
print(c)


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

int main() {
  //入力を受け取る
  int a_energy, a_attack, b_energy, b_attack;
  cin >> a_energy >> a_attack >> b_energy >> b_attack;

    while(true)
    {
        a_energy = a_energy - b_attack;
        b_energy = b_energy - a_attack;
        
        if(b_energy <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        else if(a_energy <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }
}


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

int main(void){

    int N;
    int abuf;
    vector<int> a;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> abuf;
        a.push_back(abuf);
    }

    vector<int> b;
    b.assign(N, 0);

    for(int i=N; i>N/2; i--){
        if(a[i-1]==1){
            b[i-1]=1;
        }
    }

    int sumb;

    for(int i=N/2; i>0; i--){
        sumb = 0;
        for(int j=i; j<=N; j+=i){
            sumb += b[j-1];
        }
        if(sumb%2 != a[i-1]){
            b[i-1] = 1;
            sumb++;
        }
    }

    if(N==1 && a[0]==1){
        sumb = 1;
    }

    cout << sumb << endl;
    bool firstout = true;
    for(int i=0; i<N; i++){
        if(b[i]==1){
            if(!firstout)cout << " ";
            cout << i+1;
            firstout = false;
        }
    }
    if(!firstout)cout << endl;

    return 0;
}

Measured memory_bytes: 2676
N=int(input())
alist=list(map(int,input().split()))

def bs_left(mid,mp):
  sum1=sum2=abs(2*slist[mid]-slist[mp])
  sum3=abs(2*slist[mid+1]-slist[mp])
  if mid>0:
    sum1=abs(2*slist[mid-1]-slist[mp])

  if sum2<=sum1 and sum2<=sum3:
    return 0
  elif sum1<sum2:
    return -1
  elif sum2>sum3:
    return 1    

def bs_right(mid,mp):
  sum1=abs(2*(slist[mid-1]-slist[mp])-(slist[-1]-slist[mp]))
  sum2=abs(2*(slist[mid]-slist[mp])-(slist[-1]-slist[mp]))
  sum3=abs(2*(slist[mid+1]-slist[mp])-(slist[-1]-slist[mp]))

  if sum2<=sum1 and sum2<=sum3:
    return 0
  elif sum1<sum2:
    return -1
  elif sum2>sum3:
    return 1    
  
slist=[]
asum=0
for a in alist:
  asum+=a
  slist.append(asum)
#print(alist)
#print(slist)

dic_lp,dic_rp={},{}
for mp in range(1,N-2):  
  #lp
  l,r=0,mp-1
  while(l<=r):
    mid=(l+r)//2
    ret=bs_left(mid,mp)
    if ret==1:
      l=mid+1
    elif ret==-1:
      r=mid-1
    else:
      dic_lp[mp]=mid
      #print(mp,mid)
      break
  
  #rp
  l,r=mp+1,N-2
  while(l<=r):
    mid=(l+r)//2
    ret=bs_right(mid,mp)
    if ret==1:
      l=mid+1
    elif ret==-1:
      r=mid-1
    else:
      dic_rp[mp]=mid
      #print(mp,mid)
      break
    
min_diff=10**9
for mp in range(1,N-2):
  lp=dic_lp[mp]
  rp=dic_rp[mp]
  
  sum1=slist[lp]
  sum2=slist[mp]-slist[lp]
  sum3=slist[rp]-slist[mp]
  sum4=slist[-1]-slist[rp]
  #print(sum1,sum2,sum3,sum4)
  
  sum_list=[sum1,sum2,sum3,sum4]
  sum_list.sort()
  diff=sum_list[-1]-sum_list[0]
  #print(lp,mp,rp,diff)
  if diff<min_diff:
    min_diff=diff    
  
print(min_diff)

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

using namespace std;

typedef pair<int, int> Pi;
typedef pair<Pi, int> Pii;

int main()
{
  int N;
  while(cin >> N, N) {
    vector<Pii> memory;
    memory.push_back(Pii(Pi(0, 1000000001), -1)); // just divide the segments. (half-open)
    while(N--) {
      char command; cin >> command;
      if(command == 'W') {
	int I, S; cin >> I >> S;
	for(int i = 0; S > 0; i++) {
	  if(memory[i].second != -1) continue;
	  int space = memory[i].first.second - memory[i].first.first;
	  if(space <= S) { // fill the space
	    S -= space;
	    memory[i].second = I;
	  } else { // space too large so divide
	    Pii data = Pii(Pi(memory[i].first.first, memory[i].first.first + S), I);
	    memory.insert(memory.begin() + i, data);
	    memory[i+1].first.first = memory[i].first.second;
	    break;
	  }
	}
      } else if(command == 'D') {
	int I; cin >> I;
	for(int i = 0; i < memory.size(); i++) {
	  if(memory[i].second == I) memory[i].second = -1;
	}
      } else if(command == 'R') {
	int P; cin >> P;
	for(int i = 0; i < memory.size(); i++) {
	  if(P < memory[i].first.second) {
	    cout << memory[i].second << endl;
	    break;
	  }
	}
      }
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5;
int n,a[Max_N*2+5],c[Max_N*2+5],A[Max_N*2+5];
inline bool chck(int x){
	for(int i=1;i<2*n;i++) A[i]=a[i]>=c[x];
	int dis=0;
	for(;n-dis-1>=1&&!(A[n-dis-1]==A[n-dis]||A[n+dis]==A[n+dis+1]);++dis);
	if(A[n-dis-1]==A[n-dis]) return A[n-dis];
	if(A[n+dis+1]==A[n+dis]) return A[n+dis];
	return A[n]==(n&1);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<2*n;i++) scanf("%d",&a[i]),c[i]=a[i];
	sort(c+1,c+2*n);
	int l=1,r=2*n-1;
	for(;l<r;){
		int mid=(l+r+1)>>1;
		if(chck(mid)) l=mid;
		else r=mid-1;
	}
	printf("%d\n",c[l]);
	return 0;
}

Measured memory_bytes: 6160
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    ll l,r;
    cin>>l>>r;
    ll q=r-l+1;
    if(q>=2019){
        cout<<0<<endl;
        return 0;
    }else{
        int ans=2019;
        for(ll i=l;i<=r;++i){
            for(ll j=i+1;j<=r;++j){
                int temp=(i*j)%2019;
                ans=min(ans,temp);
            }
        }
        cout<<ans<<endl;
        return 0;
    }
}


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

int isCorrect(int *, int *, int (*)[3]);

int main(void){
    int c[3][3];
    int a[3];
    int b[3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    for(int i=0; i<=100; i++){
        a[0] = i;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        if(isCorrect(a, b, c)){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

int isCorrect(int *a, int *b, int (*c)[3]){
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(a[i]+b[j] != c[i][j]){
                    return 0;
                }
            }
        }
        return 1;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;

int main(void){
  int a,b,c;
  vector<int> color(101,0);
  cin >> a >> b >> c;
  color[a] = 1;
  color[b] = 1;
  color[c] = 1;
  cout << accumulate(color.begin(), color.end(), 0) << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
typedef long long LL;
const int N = 200005;
const int K=31;  
const int M=10921000; 
const int INF = 0x3f3f3f3f; 
const LL MOD = 998244353;
int n,m;
int a,b;
struct nd
{
    int v,nxt;
}edge[N<<2];
int head[N],cnt;
int ans;
int vis[N];
void ini()
{
    memset(head,-1,sizeof head);
    cnt=0;
}
void add_edge(int a,int b)
{
    edge[cnt].v = b;
    edge[cnt].nxt = head[a];
    head[a] = cnt++;
}
void dfs(int x,int col)
{
    // cout<<x<<" "<<fa<<endl;
    vis[x]=col;
    for (int i=head[x];~i;i=edge[i].nxt)
    {
        int e = edge[i].v;
        if (vis[e]!=-1)
            continue;
        dfs(e,1-col);
    }
}
int main ()
{
    while (~scanf("%d%d",&n,&m))
    {
        ini();
        for (int i=0;i<m;i++)
        {
            scanf("%d%d",&a,&b);
            add_edge(a,b);
            add_edge(b,a);
        }
        memset(vis,-1,sizeof vis);
        dfs(1,0);
        int f=0,tmp=0;
        for (int i=1;i<=n && !f;i++)
        {
            for (int j=head[i];~j;j=edge[j].nxt)
            {
                int e=edge[j].v;
                if (vis[e]==vis[i])
                {
                    f=1;
                    break;
                }
            }
            if (vis[i])
                tmp++;
        }
        // cout<<f<<" "<<tmp<<endl;
        if (f==0)
            printf("%lld\n", (LL)tmp*(LL)(n-tmp)-m);
        else
            printf("%lld\n", (LL)(n)*(LL)(n-1)/2-m);
    }
    return 0;
}
 
/*
 
6 5
1 2
2 3
3 4
4 5
5 6
 
*/

Measured memory_bytes: 5248
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def floor_sum_1(n, m, a, b):
    ret = 0
    if a >= m:
        ret += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ret += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ret
    ret += (n - (x_max + a - 1) // a) * y_max
    ret += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ret


def floor_sum(n, m, a, b):
    ret = 0
    while True:
        if a >= m:
            # ret += (n - 1) * n * (a // m) // 2
            ret += (a // m) * (n - 1) * n // 2
            a %= m
        if b >= m:
            ret += n * (b // m)
            b %= m
        if a * n + b < m:
            return ret
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        ret += (n - (x_max + a - 1) // a) * y_max
        n = y_max
        m, a, b = a, m, (a - x_max % a) % a


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    # parse input
    T = int(input())
    for _t in range(T):
        N, M, A, B = map(int, input().split())
        print(floor_sum(N, M, A, B))


# tests
T1 = """
5
4 10 6 3
6 5 4 3
1 1 0 0
31415 92653 58979 32384
1000000000 1000000000 999999999 999999999
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
13
0
314095480
499999999500000000
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


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

using namespace std;

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

	long long n,q;
	cin>>n;

	long long arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	
  	cin>>q;
  	long long query[q][2];
	for(int i=0;i<q;i++)
		cin>>query[i][0]>>query[i][1];

	long long cnt[100001]={0};

	long long sum=0;
	for(int i=0;i<n;i++)
	{
		cnt[arr[i]]++;
		sum+=arr[i];
	}

	for(long long i=0;i<q;i++)
	{
		sum-=(query[i][0]*cnt[query[i][0]]);
		sum+=(query[i][1]*cnt[query[i][0]]);
		cnt[query[i][1]]+=cnt[query[i][0]];
		cnt[query[i][0]]=0;

		cout<<sum<<"\n";
	}
	return 0;
}

Measured memory_bytes: 6740
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <memory>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D);

	return 0;
}

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

using namespace std;

int main() {
    int x,y;
    int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    cin>>x>>y;
    if(a[x]==a[y])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

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

pats = []
for pat in range(1<<(W-1)):
    for i in range(W-2):
        if pat & (1<<i) and pat & (1<<(i+1)):
            break
    else:
        pats.append(pat*2)

dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        for pat in pats:
            L = pat & (1<<j)
            R = pat & (1<<(j+1))
            if L == 0 and R == 0:
                dp[i+1][j] += dp[i][j]
            elif L != 0 and R == 0:
                dp[i+1][j-1] += dp[i][j]
            elif L == 0 and R != 0:
                dp[i+1][j+1] += dp[i][j]
    for j in range(W):
        dp[i+1][j] %= MOD

print(dp[H][K-1])


Measured memory_bytes: 3064
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
s = 0
for i in range(n):
    for j in range(i + 1, n):
        c = 0
        for k in range(2):
            c += (l[i][k] - l[j][k]) ** 2
        s += c ** (1 / 2)
print(2 * s / n)

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

int main(){
    int n;
    cin >> n;
    vector<long long> len_el(n);
    long long length = 0;
    for(int i=0; i<n; i++){
        cin >> len_el[i]; 
        length += len_el[i];
    }
    long long inf=0,sup=0;
    int i = 0;
    while(true){
        sup += len_el[i];
        if(sup*2>=length) break;
        inf += len_el[i];
        i++;
    }
    long long inf_red=length-inf;
    long long sup_res=length-sup;
    long long ans = min(inf_red-inf, sup-sup_res);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    int n = s.size();
    
    string ans = "AC";
    if (s[0]!='A') ans = "WA";
    map<char, int> mp;
    rep(i, n) {
        if (i<=1) continue;
        if (i==n-1) continue;
        mp[s[i]]++;
    }
    if (mp['C']!=1) ans = "WA";
    rep(i, n) {
        if (s[i]=='A' || s[i]=='C') continue;
        if (s[i]<'a' || s[i]>'z') ans = "WA";
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;

#define FOR(i,a,b) for(ll i=(a); i < (b); (i)++)

#define DBG 0
#define TR(X) ({if (DBG) cerr << "TR " << (#X) << " = " << (X) << endl; })
#define TRM(i,j,c) ({if (DBG) cerr << "TR (" << (i) << ", " << (j) << ") = " << (c)[i][j] << endl;})

int main(void){
    cin.sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;

    vvl dp(s.size() + 1 , vl(t.size() + 1, 0));

    FOR(i,1,s.size() + 1) FOR(j,1,t.size()+1){
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        if(s[i-1] == t[j-1]){
            dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
        TRM(i,j,dp);
    }
    ll idx_i = s.size(),
       idx_j = t.size();
    vector<char> res(dp[s.size()][t.size()]);

    while(idx_i >= 1 && idx_j >= 1){
        ll left = dp[idx_i-1][idx_j];
        ll up = dp[idx_i][idx_j-1];
        ll lup = dp[idx_i-1][idx_j-1];

        TRM(idx_i,idx_j,dp);
        TR(dp[idx_i-1][idx_j]);
        TR(dp[idx_i][idx_j-1]);

        if(s[idx_i-1] == t[idx_j-1] && lup <= up && lup <= left){
            res[dp[idx_i][idx_j] - 1] = s[idx_i - 1];
            TR(res[dp[idx_i][idx_j] - 1]);

            idx_i--;
            idx_j--;
        } else if(up == left) {
            if( idx_i < idx_j ){
                idx_j--;
            } else {
                idx_i--;
            }
        } else if(up > left){
            if(idx_j == 1){
                idx_i--;
            } else
                idx_j--;
        } else {
            if(idx_i == 1){
                idx_j--;
            } else
                idx_i--;
        }
    }
    for(const auto &it : res){
        cout << it;
    }
    cout << endl;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]and s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";

}


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

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

  if (A+B > C+D) {
    cout << "Left" << endl;
  } else if (A+B < C+D) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


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

int main() {
  char c = 'a';
    cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

int n; char s[maxn];

int main() {
    cin >> n >> s + 1;
    int c1 = 0, c2 = 0;
    for (int i = 1; i <= n; i++) if (s[i] == 'R') c1++; else c2++;
    if (c1 > c2) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8
s = input()
n = len(s)

m = (n-1)//2
k = (n+3)//2

#検査する文字列と、それをそのまま反転したものを比較し一致すれば回文
if s == s[::-1] and s[:m] == s[:m][::-1] and s[k-1:] == s[k-1:][::-1]:
    print('Yes')
else:
    print('No')


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

int main() {
    int N;
    cin >> N;
    string str;
    cin >> str;
    int bound = 0, r = 0, w = 0;
    rep(i, N) {
        if(str[i] == 'R') {
            bound++;
        }
    }
    rep(i, N) {
        if(i < bound and str[i] == 'W') {
            w++;
        } else if(i >= bound and str[i] == 'R') {
            r++;
        }
    }
    cout << max(r, w) << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007

using namespace std;

void solve () {
	int n,m;
	cin >> n >> m;
	char grid[n][m];
	for (int i = 0;i < n;++i) {
		for (int j = 0;j < m;++j) {
			cin >> grid[i][j];
		}
	}
	int dp[n][m];
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	int i = 1,j = 1;
	while (i < n) {
		if (grid[i][0] == '#') {
			++i;
			break;
		}
		dp[i][0] = 1;
		++i;
	}
	while (i < n) {
		dp[i][0] = 0;
		++i;
	}
	while (j < n) {
		if (grid[0][j] == '#') {
			++j;
			break;
		}
		dp[0][j] = 1;
		++j;
	}
	while (j < n) {
		dp[0][j] = 0;
		++j;
	}
	for (i = 1;i < n;++i) {
		for (j = 1;j < m;++j) {
			if (grid[i][j] == '#') {
				dp[i][j] = 0;
			} else {
				dp[i][j] = (dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
			}
		}
	}
	cout << dp[n-1][m-1] << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;	
}



Measured memory_bytes: 5120
import java.util.*;
import java.io.*;
class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      	OutputStream outputstream = System.out;
      	//PrintWriter out = new PrintWriter(outputstream);
      	int N = in.nextInt();
      	int L = in.nextInt();
      	String[] s = new String[N];	
      	for(int i =0;i<N;i++){
          	s[i] = in.next();
        }
      	Arrays.sort(s);
      	String ans = "";
      	for(int i =0;i<N;i++){
        	ans+=s[i];
        }
      	System.out.println(ans);
    }
}

Measured memory_bytes: 25556
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int n, k;
int child[2005], prt[2005];
ll dp[2005][2005];
//dp[i][j]:iの部分木の深さをj以下にするために削除する頂点数の最小値
//最後に求めるのはdp[i][k]
//マージ：完全に切り離すかくっつつけるか。
//もし次のをくっつつけてもkを超えないならくっつつけてよい
//くっつつける深さ+1がjを超えるかで場合分け。
vii edges[2005];
void dfs(int now){
    child[now]++;
    dp[now][0] = 1;
    dp[now][1] = 0;
    for(auto nex:edges[now]){
        if (prt[now]==nex)
            continue;
        prt[nex] = now;
        dfs(nex);
        //dp[nex]が求まった。
        //dp[now]がmxまで定まっているとする。最大でもchild
        //dp[now][i]とdp[nex][j]をマージすることを考える。
        //nexの最大深さはchild[nex]程度
        
        repr(i,1+child[now],-1){
            ll tmp = dp[now][i];
            dp[now][i] = infi;
            repr(j,1+child[nex],-1){
                //i+j+1>kの場合は完全に切り離すだけ。
                //もしそうじゃないなら切り離すか、くっつつけるか選べる。
                if (i+j-1>k){
                    dp[now][i] = min(dp[now][i], tmp + child[nex]);
                }
                else{
                    //くっつつけてよい
                    if (j+1>i){
                        dp[now][j + 1] = min(dp[now][j + 1], tmp + dp[nex][j]);
                        dp[now][i] = min(dp[now][i], tmp + child[nex]);
                    }
                    else{
                        //くっつつけられて増えないならそのまま
                        dp[now][i] = min(dp[now][i], tmp + dp[nex][j]);
                    }
                }
            }
        }
        child[now] += child[nex];
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].eb(b);
        edges[b].eb(a);
        prt[i] = -1;
        child[i] = 0;
    }
    prt[n - 1] = -1;
    child[n - 1] = 0;
    rep(i,n+1){
        rep(j, n+1) dp[i][j] = infi;
    }
    dfs(0);
    ll ans = infi;
    rep(i,n){
        rep(j,k+2){
            ans = min(ans, dp[i][j] + (n - child[i]));
        }
    }
    cout << ans << ENDL;
}


Measured memory_bytes: 31872
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int flag1 = 0, flag2 = 0;
    std::string str;
    std::cin >> str;

    for (int i = 0; i < str.size() + 1; i++)
    {
        if (str[i]=='C')
        {
            flag1 = 1;
        }

        if (flag1 == 1 && str[i] == 'F')
        {
            flag2 = 1;
        }
    }
    if (flag2 != 1)
    {
        std::cout << "No" << std::endl;
    }

    if (flag2 == 1)
    {
        std::cout << "Yes" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 888
N = int(input())

P = []
for _ in range(N):
  x,l = list(map(int, input().split()))
  P.append((x+l, x-l))
  
P.sort()
rw = P[0][0]
ans = 1
for i in range(1,N):
  r,l = P[i]
  if l < rw:
    continue
  else:
    rw = r
    ans += 1
    
print(ans)


Measured memory_bytes: 17032
#include<iostream>
#include<cstdio>
using namespace std;
int n;
void Counting_Sort(int A[],int B[],int k){
  int *C = new int[k+1];
  for(int i=0;i<=k;i++)C[i]=0;
  for(int j=1;j<=n;j++)C[A[j]] = C[A[j]] + 1;
  for(int i=1;i<=k;i++)C[i]=C[i]+C[i-1];
  for(int j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  delete [] C;
}

int main(){
  while(scanf("%d",&n) != EOF){
    int k=0;
    int *A = new int[n+2];
    int *B = new int[n+2];
    for(int i=1;i<=n;i++){
      scanf("%d",&A[i]);
      if(k<A[i])k=A[i];
    }
    Counting_Sort(A,B,k);

    for(int i=1;i<=n;i++){

      printf("%d",B[i]);

      if(i != n)printf(" ");

    }
    printf("\n");
    delete [] A;
    delete [] B;

  }

  return 0;

}

Measured memory_bytes: 16000
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	string k;
  	cin >> k;
  	int c =0,m = -1;
  	for (int i = 0; i < k.size(); ++i)
  	{
  		if (k[i] == 'B')
  		{
  			m = max(m,i);
  		}
  	}
  	for (int i = m; i >= 0; i--)
	{
		
		if(k[i] != 'B' && c > 0)
		{
			k[i] = 'Z';
			c--;
		}
		if (k[i] == 'B')
			c++;
	}
	for (int i = 0; i < k.size(); ++i)
	{
		if (k[i] != 'B' && k[i] != 'Z')
		{
			cout << k[i];
		}
	}
   	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int r = sc.nextInt();
		int g = sc.nextInt();
		System.out.println(g * 2 - r);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

}


Measured memory_bytes: 21204