akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int[] W = new int[N];
        int sum = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
            sum+=W[i];
		}
        int ans = 0;
        int min = 0;
        boolean first = true;
		for (int i = 0; i < N; i++) {
        int s1 = 0;
		for (int j = 0; j <= i; j++) {
			s1+=W[j];
		}
        int s2 = sum - s1;
        int sa = Math.abs(s1-s2);
        if(first || min > sa){
          min = sa;
        }
        if(first){
          first = false;
        }
		}
		System.out.println(min);
	}		
}


Measured memory_bytes: 21844
#include<stdio.h>
    
int main(){
    
double a;
  
while(scanf("%lfn", &a)!=EOF){
  
 
  if(a<=48.00){printf("light fly\n");}
  else if(a>48.00 && a<=51.00){printf("fly\n");}
  else if(a>51.00 && a<=54.00){printf("bantam\n");}
  else if(a>54.00 && a<=57.00){printf("feather\n");}
  else if(a>57.00 && a<=60.00){printf("light\n");}
  else if(a>60.00 && a<=64.00){printf("light welter\n");}
  else if(a>64.00 && a<=69.00){printf("welter\n");}
  else if(a>69.00 && a<=75.00){printf("light middle\n");}
  else if(a>75.00 && a<=81.00){printf("middle\n");}
  else if(a>81.00 && a<=91.00){printf("light heavy\n");}
  else if(a>91.00){printf("heavy\n");}
  
}
    
    return 0;
}

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

using namespace std;

typedef long long int_t;

int_t fact[4000000],finv[4000000];
const int_t mod = 1000000007;
int_t dp[2010][2010];

int_t C(int_t a,int_t b){
    return fact[a] * finv[b] % mod * finv[a-b] % mod;
}

int main(){
    int_t n,k; cin>>n>>k;
    if(k == 1){ cout<< 1; return 0;}
    fact[0] = fact[1] = finv[1] = finv[0] = dp[0][0] = 1;
    for(int_t i=2;i<4000000;i++) fact[i] = fact[i-1] * i % mod, finv[i] = (mod - mod / i) * finv[mod % i] % mod;
    for(int_t i=2;i<4000000;i++) finv[i] = finv[i] * finv[i-1] % mod;
    for(int_t i=1;i<=n;i++)
        for(int_t j=0;j<=i;j++){
            dp[i][j] = dp[i-1][j];
            if(j) dp[i][j] = (dp[i][j] + dp[i][j-1] * (n - j + 1) % mod * C(n - i + (n - j + 1) * (k - 1) - 1, k - 2)%mod)%mod;
        }
    cout<<dp[n][n];
}

Measured memory_bytes: 92800
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N;
   cin >> N;
   cout << (N-1)/2<<endl;
   return 0;
}


Measured memory_bytes: 256
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 
void solve() {
    int n,k;
    cin>>n>>k;
    int h[n];
    rep(i,0,n)
        cin>>h[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = dp[0] + abs(h[1] - h[0]);
    rep(i,2,n)
    {
        dp[i] = INT_MAX;
        for(int j = i-1;j>=max(i-k,0);j--)
        {
            dp[i] = min(dp[i],dp[j] + abs(h[i] - h[j]));
        }
    }
   cout<<dp[n-1]<<endl;
}
 
signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int n, m, a,ans=0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		ans += a;
	}
	if (ans > n)
		cout << "-1";
	else
		cout << n - ans;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define K 100011
#define N 111

using namespace std;

int n, k, arr[N];
bool win[K];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> arr[i];
	for(int i=0; i<=k; i++) {
		win[i] = false;
		for(int j=0; j<n; j++) {
			if(arr[j] > i) continue;
			if(!win[i - arr[j]]) win[i] = true;
		}
	}
	cout << (win[k] ? "First\n" : "Second\n");
	return 0;
}


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

int main() {
    string s,t;
    cin >> s >> t;
    int zb=0;
    for (int i=0; i<s.size(); i++) {
        if (s[i]!=t[i]) {zb++;}
    }
    cout << zb;
}


Measured memory_bytes: 3916
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans,a,b;
int main(void){
    string s;
    cin>>s;
    ans=s.size();
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')a++;
        else b++;
    }
    cout<<ans-abs(a-b)<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble(),y1 = sc.nextDouble(),x2 = sc.nextDouble(),y2 = sc.nextDouble();
        System.out.printf("%.8f\n",Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    }

}

Measured memory_bytes: 28020
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

long long int N;
vector<char> c;

int main(){
    cin >> N;
    char a = 'a';
    int R_amo = 0;

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

        if(c[i] == 'R') {
            R_amo++;
        }

    }

    int W_amo = 0;
    for(int i = 0;i < R_amo;i++){
        if(c[i] == 'W') W_amo++; 
    }

    cout << W_amo << endl;


}

Measured memory_bytes: 3776
#include <stdio.h>

int n, A[50] ;

int solve(int i , int m)
{
    if( m == 0 )
    {
        return 1 ;
    }
    if( i >= n )
    {
        return 0 ;
    }
    
    int res = solve(i+1, m) || solve(i+1, m-A[i]) ;
    return res ;
}

int main()
{
    int q, M, i ;
    scanf("%d",&n) ;
    for(i = 0; i < n ; ++i)
    {
        scanf("%d", &A[i] ) ;
    }
    scanf("%d", &q) ;
    for( i = 0; i < q ; i++)
    {
        scanf("%d",&M) ;
        if( solve(0,M))
        { 
            printf("yes\n");
        }
        else
        {
            printf("no\n") ;
        }
    }
    return 0 ;
}



Measured memory_bytes: 2696
#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)
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b;
  cout << (a + b) % 24 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for(int i = 0; i<n; i++){
    cin >> p[i];
  }
  
  vector<bool> judge(105, true);
  for(int i = 0; i < n; i++){
    judge[p[i]] = false;
  }
  
  for(int i = 0; i < 100; i++){
    if(judge[x-i]){
      cout << x-i << endl;
      break;
    }
    else if(judge[x+i]){
      cout << x+i << endl;
      break;
    }
  }
}

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

int main() {
    int sum = 0;
    char n;
    for (int i = 0; i < 4; i++) {
        cin >> n;
        if ((int)n ==43) {
            sum += 1;
        }
        else if((int)n==45) {
            sum -= 1;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<int> x(n),a(n);
    for(int i=0; i<n; i++) {
        cin >> x[i];
        a[i] = x[i];
    }
    sort(x.begin(), x.end());
    for(int i=0; i<n; i++) {
        if(a[i]>=x[n/2]) {
            cout << x[n/2-1] << endl;
        } else {
            cout << x[n/2] << endl;
        }
    }
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
int a[1111];
double ans=0;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	sort(a,a+n);
	ans+=a[0];
	FOR(i,1,n){
		ans+=a[i];
		ans/=2;
	}
	printf("%.10lf\n",ans);
	
	return 0;
}


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int numT = ceil(float(C) / B);
    int numA = ceil(float(A) / D);

    if(numT <= numA){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n;

int main()
{
	scanf ("%d", &n);
	int a = n / 10;
	int b = n % 10;
	if (a == 9 || b == 9)	printf ("Yes\n");
	else printf ("No\n");
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
int z[a];
for(int i=0;i<a;i++){
cin>>z[i];
}
for(int i=a-1;i>=0;i--){
  cout<<z[i];
  if(i!=0)
  cout<<' ';
}
cout<<'\n';
return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
int a[210];
int main(){
	int n,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	while(true){
		for(int i=1;i<=n;i++){
		    if(a[i]%2==1){
			    cout<<s<<"\n";
			    return 0;
		    }
		    a[i]/=2;
		}
		s++;
	}
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let k = read();
    let h: Vec<u32> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    for i in 0..n {
        if h[i] >= k {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	VI a(5);
	int k;
	REP(i, 5)
		cin >> a[i];
	cin >> k;
	sort(ALL(a));
	if (a[4] - a[0] > k) {
		cout << ":(";
		return 0;
	}
	cout << "Yay!";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=min(r[a]/vr[a],r[b]/vr[b]),M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4476
N, M = map(int, input().split())
adjs = [list() for _ in range(N)]
vis = [False for _ in range(N)]

def dfs(v, cnt):
    if vis[v]:
        return 0
    vis[v] = True
    cnt += 1
    ka = 0
    for x in adjs[v]:
        ka += dfs(x, cnt)
    if cnt == N:
        ka = 1
    vis[v] = False
    return ka

for _ in range(M):
    a, b = map(int, input().split())
    adjs[a-1].append(b-1)
    adjs[b-1].append(a-1)
print(dfs(0, 0))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

namespace ABC088_B_Card_Game_for_Two
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' ');
			List<int> aLists = new List<int>();
			
			for (int i = 0; i < n; i++) {
				aLists.Add(int.Parse(input[i]));
			}
			aLists.Sort();
			aLists.Reverse();

			int alicePoint = 0;
			int bobPoint = 0;

			for (int i = 0; i < n; i++)
			{
				if (i % 2 == 0) alicePoint += aLists[i];
				if (i % 2 == 1) bobPoint += aLists[i];
			}
			
			Console.WriteLine(alicePoint - bobPoint);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc028_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, M;
  cin >> N >> M;

  string S, T;
  cin >> S >> T;

  ll L = lcm(N, M);
  map<ll, int> s;
  map<ll, int> t;
  rep(i, N) {
    ll j = (L / N) * i + 1;
    s[j] = i;
  }
  rep(i, M) {
    ll j = (L / M) * i + 1;
    t[j] = i;
  }

  for (auto _s : s) {
    ll p = _s.first;
    if (t.find(p) != t.end()) {
      int i = _s.second;
      int j = t[p];
      if (S[i] != T[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (auto _t : t) {
    ll p = _t.first;
    if (s.find(p) != s.end()) {
      int i = _t.second;
      int j = s[p];
      if (T[i] != S[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  cout << L << endl;
}

Measured memory_bytes: 14160
// https://atcoder.jp/contests/abc174/tasks/abc174_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;
    int idx1 = 0, idx2 = N - 1, ans = 0;
    while (idx1 < idx2) {
        // idx1はWを探す
        while (S[idx1] != 'W') {
            idx1++;
            if (idx1 > idx2) {
                break;
            }
        }
        // idx2はRを探す
        while (S[idx2] != 'R') {
            idx2--;
            if (idx1 > idx2) {
                break;
            }
        }
        if (idx1 > idx2) {
            break;
        }
        ans++;
        S[idx1] = 'R';
        S[idx2] = 'W';
        idx1++;
        idx2--;
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	unordered_map<string, long long> m;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;

		sort(s.begin(), s.end());

		if (m.find(s) == m.end()) {
			m[s] = 1;
		}
		else {
			++m[s];
		}
	}
	
	long long ret = 0;
	for (auto& i : m) {
		ret += i.second * (i.second - 1LL) / 2LL;
	}

	cout << ret << endl;


	return 0;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll N,K;
vector<ll> A;

ll F(ll x){
  ll res = 0;
  rep(i,N){
    ll l = -1,r = N;
    if(A[i] == 0){
      if(x <= 0){
        res += N-1;
        //cout << A[i] << ' ' << N-1 << endl;
        continue;
      }
    }
    if(A[i] < 0){
      while(r-l > 1){
        ll mid = (l+r)/2;
        if(A[i] * A[mid] >= x) l = mid;
        else r = mid;
      }
      if(A[i] * A[i] >= x){
        res += l;
        //cout << A[i] << ' ' << l << endl;
      }else{
        res += l+1;
        //cout << A[i] << ' ' << l + 1 << endl;
      }
    }else{
      while(r-l>1){
        ll mid = (l+r)/2;
        if(A[i] * A[mid] >= x) r = mid;
        else l = mid;
      }
      if(r != N){
        if(A[i]*A[i] >= x){
          res += N - r - 1;
          //cout << A[i] << ' ' << N-r-1 << endl;
        }else{
          res += N - r;
          //cout << A[i] << ' ' << N-r << endl;
        }
      }else{
        //cout << A[i] << ' ' << 0 << endl;
      }
    }
  }
  return res / 2;
}

int main(){
  cin >> N >> K;
  K = N * (N-1) / 2 - K + 1;
  rep(i,N){
    ll a;cin >> a;
    A.emplace_back(a);
  }
  sort(ALL(A));
  cout << endl;
  ll l = -1000000000000000010,r = 1000000000000000010;
  while(r-l > 1){
    ll mid = (l+r) / 2;
    if(F(mid) >= K) l = mid;
    else r = mid;
  }
  cout << l << endl;
}


Measured memory_bytes: 2420
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10, M = 1e3;

bool solve(ll a, ll b, ll c, ll d);
bool simulate(ll a, ll b, ll c, ll d);

int main() {
	int t; cin >> t;
	while (t--) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if (solve(a, b, c, d)) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
	// cout << __gcd(999999999999999985, 17ll) << endl;
}

bool solve(ll a, ll b, ll c, ll d) {
	if (d < b or a < b) {
		return false;
	} else if (c >= b - 1) {
		return true;
	} else {
		if (!simulate(a, b, c, d)) {
			return false;
		} else if (__gcd(b, d) <= b - c - 1) {
			return false;
		} else {
			return true;
		}
	}
}

bool simulate(ll a, ll b, ll c, ll d) {
	int steps = M;
	while (steps--) {
		if (a < b) {
			return false;
		}
		ll i = (a - c + b - 1) / b;
		a -= i * b;
		if (a < 0) {
			return false;
		}
		a += d;
	}
	return true;
}

Measured memory_bytes: 384
/*
C++ のソースコードのテンプレート
特にAOJ-ITP1に使いやすい
*/
#define _USE_MATH_DEFINES

#include <iostream> // 標準入出力
#include <fstream>  // ファイル入出力
#include <string>   // 文字列関係
#include <vector>   // 可変の配列
#include <cmath>    // 数学系
#include <iomanip>  // streamの書式関係
#include <algorithm>// max関数など

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // 要素数が可変のベクトル
using std::fixed;         // ストリームの設定をデフォルトにする
using std::setprecision;  // 引数に小数点以下の桁数を指定することが出来る

int main() {
	string S;
	cin >> S;
	for (size_t i = 0; i < S.size(); i++)
	{
		if (i % 2 == 0) {
			cout << S[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 100005

ll x;

int main(){
    int i,j;
    cin>>x;
    for(i=1;i<=120;i++){
        for(j=0;j<i;j++){
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout<<i<<" "<<j;
                return 0;
            }
            if(i*i*i*i*i+j*j*j*j*j==x){
                cout<<i<<" "<<-j;
                return 0;
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void)
{
    int A, B, K;
    int count=0;
    int d[105];

    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &K);

    for(int i=0 ;i<105 ;i++)
    {
        d[i] = 1;
    }

    for(int i=100; i>0 ;i--)
    {
        if( (A%i==0) && (B%i==0) )
        {
            count+=1;
            d[count] = i;
        }
    }
    printf("%d", d[K]);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,H;
    cin>>N>>H;
    vector<ll> a(N),b(N);
    ll a_max=0;
    REP(i,N){
        cin>>a[i]>>b[i];
        a_max=max(a_max,a[i]);
    }
    sort(b.rbegin(),b.rend());
    ll ans=0;
    REP(i,N){
        //cout<<b[i]<<endl;
        if(b[i]>a_max) ans++,H-=b[i];
        else break;
        if(H<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    ans += (H+a_max-1)/a_max;

    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ld long double
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n" 
//#pragma GCC optimize(2)
using namespace std;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//const double eps(1e-8);
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=2e5+10;
const int M=1e9+7;
int n;
int f[N],x;
int main(){Accel
	cin>>n;
	int t=0;
	FOR(i,1,n){
		cin>>x;
		f[x]=f[x-1]+1;
		t=max(t,f[x]);
	}
	cout<<n-t<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

#define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define en '\n'
#define S second
#define F first
#define pll pair<ll,ll>
#define PB push_back

const ll N = 1e6+7;
ll mod = 1e9+7;
#define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
ll fac[N] = {0};

ll gen_base(const ll before, const ll after) {
    auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::mt19937 mt_rand(seed);
    int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
    return base % 2 == 0 ? base-1 : base;
}

ll pow(ll a,ll b)
{
    if(!b)
        return 1;
    ll p = pow(a,b/2);
    if(b%2)
        return (a*((p*p)%mod))%mod;
    else
        return (p*p)%mod;
}

ll modInv(ll a)
{
    //cout<<a<<" "<<mod<<en;
    return pow(a%mod,mod-2);
}

ll nCr(ll n,ll r)
{
    return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
}

ll hashf(ll r,ll x,ll mod)
{
    return (x+r)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    fac[0] = 1;
    calncr;
    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    ll t = min(k,x/d+1);
    x-=(d*t);
    k-=t;
    if(!k){
        cout<<abs(x)<<en;
        return 0;
    }
    x = abs(x+(k%2)*d);
    cout<<x<<en;
}


Measured memory_bytes: 11464
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = Math.max(A, B);
		if(A>B){
			A--;
		}else{
			B--;
		}

		ans += Math.max(A,B);

		System.out.println(ans);


	}


}


Measured memory_bytes: 23252
import scala.io.StdIn._

trait Solver extends App {
  implicit class Pipe[T](x: T) {
    def |>[U](f: T => U) = f(x)
  }

  def even(n: Long): Boolean = n % 2 == 0

  def solve(xs: List[Long], acc: Long): Long = {
    if(xs.forall(even)) solve(xs map {_ / 2}, acc + 1)
    else acc
  }
}

object Main extends Solver {
  val _ = readLine()
  val xs = readLine().split(" ").toList.map(_.toLong)
  solve(xs, 0) |> println
}

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

int main() {
  int A,B,C,N,M;
  cin >> A >> B;
  C = 0; //回文数の個数
  N = A; //調べる数
  int s1,s2,s3,s4,s5; //各桁の数
  for (int i = 0; i < B - A + 1; i++){
    M = N;
    s1 = M % 10; M /= 10;
    s2 = M % 10; M /= 10;
    s3 = M % 10; M /= 10;
    s4 = M % 10; M /= 10;
    s5 = M % 10;
    
    if ((s1 == s5) && (s2 == s4)){
    C++;
    }
    N++;
  }
  
  cout << C << endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
    #include <algorithm>
     
    int x, a, b;
     
    int main(){
        scanf("%d %d %d", &x, &a, &b);
     
        a = std::abs(x - a);
        b = std::abs(x - b);
     
        printf("%c\n", a < b ? 'A' : 'B');
     
        return 0;
    }

Measured memory_bytes: 128
n,m=map(int,input().split())
p=[1]*n
q=[0]*n
q[0]+=1
for i in range(m):
    x,y=map(int,input().split())
    p[y-1]+=1
    p[x-1]-=1
    if q[x-1]==1:
        q[y-1]=1
        if p[x-1]==0:
            q[x-1]=0
print(sum(q))

Measured memory_bytes: 4596
n,k,q,*a=map(int,open(0).read().split())
s=sorted
m=1e18
for b in a:
    i=[i for i,t in enumerate(a)if t<b]
    l=s(u for t in[s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])]for u in t)
    if len(l)>=q:m=min(m,l[q-1]-b)
print(m)

Measured memory_bytes: 57564
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  int a[5];
  rep(i,5) cin >> a[i];
  int b[] = {0,1,2,3,4};
  int mtime = 1e5;
  int time;
  rep(i,120){
    time = 0;
    rep(j,5){
      time += a[b[j]];
      if(time%10!=0 && j!=4){
        time += (10-time%10);
      }
    }
    mtime = min(mtime,time);
    next_permutation(b,b+5);
  }
  printf("%d\n", mtime);

  return 0;
}


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

int main() {
    vector<int> A(3);
    for (int i = 0; i < 3; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    if (A[0] == 5 && A[1] == 5 && A[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)

struct segtree{
  vector<int> datasum;
  vector<int> delay;
  
  int n;
  
  void init(int _n){
    n = 1;
    while( n < _n ) n *= 2;
    datasum.resize( 2 * n );
    delay.resize( 2 * n );
  }

  void delaycalc(int k){
    datasum[k] = datasum[k] + delay[k];
    if( k + 1 < n ){
      for(int i=1;i<=2;i++){
        delay[2 * k + i] = delay[ 2 * k + i] + delay[k];
      }
    }
    delay[k] = 0;
  }

  void add(int a,int b,int x,int k,int l,int r){
    delaycalc(k);
    if( r <= a || b <= l ) return;
    else if( a<= l && r <= b ) {
      delay[k] = x;
      delaycalc(k);
    } else {
      add( a, b, x, 2*k + 1, l, (l+r)/2 );
      add( a, b, x, 2*k + 2, (l+r)/2, r );
      datasum[k] = min(datasum[ 2 * k + 1] , datasum[ 2 * k + 2]);
    }
  }

  int query(int a,int b,int k,int l,int r){
    delaycalc(k);
    if( r <= a || b <= l ) return INF;
    if( a <= l && r <= b ) {
      return datasum[k] + delay[k];
    } else {
      int vl = query( a, b, 2*k+1, l, (l+r)/2 );
      int vr = query( a, b, 2*k+2, (l+r)/2, r );
      return min( vl , vr );
    }
  }

  void add( int a,int b,int x) {//[a,b) add x
    add( a, b, x, 0,0, n );
  }
  int query(int a,int b){//[a,b) 's sum
    return query(a,b,0,0,n);
  }
};

segtree T;
int N,Q;
char str[300005];
set< int > U;

int main(){
  scanf("%d %d",&N,&Q);
  scanf("%s",str);
  T.init(N+2);


  for(int i=0;i<N;i++){
    if(str[i]=='('){
      T.add(i,N,1);
    }else{
      T.add(i,N,-1);
      U.insert(i);
    }
  }


  set<int> :: iterator it;
  int p,a;
  while(Q--){


    scanf("%d",&p);
    p--;
    if(str[p]=='('){
      U.insert(p);
      str[p]=')';
      T.add(p,N,-2);

      it=U.begin();
      a= *it;
      printf("%d\n",a+1);
      U.erase(it);
      str[a]='(';
      T.add(a,N,2);
    }else if(str[p]==')'){
      it=U.find(p);
      U.erase(it);
      str[p]='(';
      T.add(p,N,2);



      
      int l=0,r=N-1,m,k;
      while(l<r){
        m=(l+r)/2;
        k=T.query(m,N);
        
        if(k<2){
          l=m+1;
        }else{
          r=m;
        }
      }
      printf("%d\n",l+1);
      str[l]=')';
      T.add(l,N,-2);
      U.insert(l);
    }




  }
  return 0;
}

Measured memory_bytes: 16444
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = 0;
	if (A + B < 2 * C) {
		cout << A * X + B * Y << endl;
	}
	else {
		ans += min(X, Y) * 2 * C;
		int num = 0;
		if (X > Y) {
			num = X - Y;
			if (A < 2 * C) ans += num * A;
			else ans += num * 2 * C;
		}
		else {
			num = Y - X;
			if (B < 2 * C) ans += num * B;
			else ans += num * 2 * C;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <unordered_set>

using namespace std;

int main(){
    int n;
    cin>>n;
    unordered_set<string> st;
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        st.insert(str);
    }

    cout<<st.size()<<endl;

    return 0;
}

Measured memory_bytes: 17704
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

n = readInt()
a = readInts()

ans = 1

i = 0

def plumin(i):
	if a[i+1]-a[i]>0:
		return 1
	elif a[i+1]-a[i]<0:
		return -1
	else:
		return 0

pmarr = []
for i in range(n-1):
	x = plumin(i)
	if x!=0:
		pmarr.append(x)

#print(pmarr)
if len(pmarr)==0:
	print(ans)
	exit()
be = pmarr[0]
for i in range(1,len(pmarr)):
	if pmarr[i]==be:
		continue
	else:
		ans+=1
		if i+1==len(pmarr):
			break
		be = pmarr[i+1]

print(ans)

Measured memory_bytes: 15324
import sys
x,k,d = map(int,input().split())

if x < 0:
  x *= -1
  
if x / k > d:
  print(x - k*d)
  sys.exit()

count = k - x // d

if count % 2 == 0:
  print(x - (d * (x//d)))
else:
  print(-(x - (d * (x//d))-d))

Measured memory_bytes: 61904
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	double[] x = new double[100];
	double[] y = new double[100];
	double[] z = new double[100];
	double[] r = new double[100];
	double EPS = 1e-9;
	
	
	double dis(int i, int j) {
		return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
	}
	
	boolean connected(int i, int j) {
		return dis(i, j)-r[i]-r[j] < EPS;
	}
	
	void run() {
		double[][] cost = new double[100][100];
		double INF = Double.MAX_VALUE/2;
		double[] mincost = new double[100];
		boolean[] used = new boolean[100];
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i < n; i++) {
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
				z[i] = sc.nextDouble();
				r[i] = sc.nextDouble();
				Arrays.fill(cost[i], INF);
				mincost[i] = INF;
				used[i] = false;
			}
			
			for (int i = 0; i < n; i++) {
				for (int j = i+1; j < n; j++) {
					if (connected(i, j)) {
						cost[i][j] = cost[j][i] = 0.0;
					} else {
						cost[i][j] = cost[j][i] = dis(i, j) - r[i] - r[j];
					}
				}
			}
			
			mincost[0] = 0.0;
			double res = 0.0;
			while (true) {
				int v = -1;
				for (int u = 0; u < n; u++) {
					if (!used[u] && (v == -1 ||mincost[u] < mincost[v]))
						v = u;
				}
				
				if (v == -1) break;
				used[v] = true;
				res += mincost[v];
				
				for (int u = 0; u < n; u++) {
					mincost[u] = min(mincost[u], cost[v][u]);
				}
			}
			
			out.printf("%.3f\n", res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 57152
// 2019/12/03 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	cout << A+B+C+D+E+F-min(A, min(B, min(C, D)))-min(E, F) << endl;

	return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

double dp[3005][3005];

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

    vector<double> p(N);
    rep(i, N) cin >> p[i];

    dp[0][0] = 1;
    REP(i, 1, N) {
        rep(j, i + 1) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]);
            if (j > 0) {
                dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
            }
        }
    }

    double ret = 0;
    REP(i, N / 2 + 1, N) {
        ret += dp[N][i];
    }

    printf("%.10f\n", ret);
}



Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */
ll n;
vector<ll> x, y, h;

int main() {
  ll n;
  cin >> n;
  bool all0 = true;
  set<ll> x0, y0;
  ll inot0;
  REP(i, n) {
    ll tx, ty, th;
    cin >> tx >> ty >> th;
    x.push_back(tx);
    y.push_back(ty);
    h.push_back(th);
    if (th == 0) {
      x0.insert(tx);
      y0.insert(ty);
    }
    if (th != 0) {
      all0 = false;
      inot0 = i;
    }
  }

  if (all0) {
    REP(i, 101) {
      REP(j, 101) {
        if (!x0.count(i) && !y0.count(j)) {
          cout << i << j << 1 << endl;
        }
      }
    }
  }

  REP(cx, 101) {
    REP(cy, 101) {
      ll h_pre = h[inot0] + abs(x[inot0] - cx) + abs(y[inot0] - cy);
      bool f = true;
      REP(i, n) {
        if (h[i] != max(0ll, h_pre - abs(x[i] - cx) - abs(y[i] - cy)))
          f = false;
      }
      if (f) {
        cout << cx << ' ' << cy << ' ' << h_pre << endl;
      }
    }
  }

  return 0;
}


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

int main()
{
    int n, h, w;
    int a, b;
    int ans = 0;
    cin >> n >> h >> w;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (a >= h && b >= w)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
 
int main() {
  ll x;
  cin >> x;
  ll i = 100;
  int cnt = 0;
  while(1) {
    if(x <= i) {
      cout << cnt << "\n";
      return 0;
    }
    i = i+(i/100);
    cnt++;
  }
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

struct edge {
    int to, cost;
};
typedef pair<int, int> pii;

int V;
vector<edge> G[1000000];
ll d[1000000];

void dijkstra(int s) {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    fill(d, d + V + 10, llmax);
    d[s] = 0;
    que.push(pii(0, s));

    while (!que.empty()) {
        pii p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) {
            continue;
        }
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    V = N;
    int r[R];
    for (int i = 0; i < R; i++) {
        cin >> r[i];
    }
    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        edge e1;
        e1.to = B;
        e1.cost = C;
        G[A].push_back(e1);
        edge e2;
        e2.to = A;
        e2.cost = C;
        G[B].push_back(e2);
    }
    int dis[R][R];
    for (int i = 0; i < R; i++) {
        dijkstra(r[i]);
        for (int j = 0; j < R; j++) {
            dis[i][j] = d[r[j]];
        }
    }
    vector<int> v;
    for (int i = 0; i < R; i++) {
        v.push_back(i);
    }
    int ans = intmax;
    do {
        int num = 0;
        for (int i = 0; i < R - 1; i++) {
            num += dis[v[i]][v[i + 1]];
        }
        if (num < ans) {
            ans = num;
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
int n, a[200000], b[200001], visited[200000], c[200001];
ll dis[200000];
vector<int> v[200001];
ll k;
vector<int> ans;
int main() {
  int p = 0;
  ll cnt = 0LL;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v[a[i]].push_back(i);
    b[i] = v[a[i]].size();
  }
  do {
    if (b[p] == v[a[p]].size()) {
      cnt++;
      p = v[a[p]][0];
    } else {
      p = v[a[p]][b[p]];
    }
    p++;
    p %= n;
    if (p == 0) {
      cnt++;
    }
  } while (p != 0);
  if (cnt < k) {
    k %= cnt;
    while (k >= 2) {
      int next = v[a[p]][b[p] % v[a[p]].size()];
      next++;
      next %= n;
      if (b[p] == v[a[p]].size() || next == 0) {
        k--;
      }
      p = next;
    }
    for (int j = p; j < n; j++) {
      if (c[a[j]] == 0) {
        ans.push_back(a[j]);
        c[a[j]]++;
      } else {
        while (c[a[j]]) {
          c[ans.back()]--;
          ans.pop_back();
        }
      }
    }
  } else {
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < n; j++) {
        if (c[a[j]] == 0) {
          ans.push_back(a[j]);
          c[a[j]]++;
        } else {
          while (c[a[j]]) {
            c[ans.back()]--;
            ans.pop_back();
          }
        }
      }
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 18040
from collections import deque
h,w = map(int,input().split())
map_a = [[] for _ in range(h)]
for i in range(h):
    for c in input():
            map_a[i].append(0 if c == "#" else 1)
d = [(1,0),(0,1),(-1,0),(0,-1)]

area = 0
stack = deque()
stack.append((0,0))

while stack:
    x,y = stack.popleft()
    for u,v in d:
        m = x + u; n = y + v
        if 0<=m<h and 0<=n<w:
            if map_a[m][n]==1:
                map_a[m][n] = map_a[x][y]+1
                stack.append((m,n))
                area += 1
if map_a[-1][-1] == 1:
    print(-1);exit()

pound = 0
for i in range(h):
    for c in map_a[i]:
        if c == 1:
            pound += 1
print(area-map_a[-1][-1]+pound)


Measured memory_bytes: 3444
n=int(input())
a=list(map(int,input().split()))
x=[i for i in a if i%4==0]
b=[i for i in a if i%4!=0 and i%2==0]
if len(x)>=n//2 or +len(x)+len(b)//2>=n//2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int z = 0;
		
		if (a-b >= c ) {
			z = 0;
		} else {
			z = c - (a-b);
		}
      
		System.out.println(z);
	}

}


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

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

string s;
string ans;
cin >> s;
if(s=="Sunny"){
    ans="Cloudy";
}
if(s=="Cloudy"){
    ans="Rainy";
}
if(s=="Rainy"){
    ans="Sunny";
}
cout << ans << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int dn(int x) {
	if (x >= 100000) return 0;
	else if (x >= 10000) return 1;
	else if (x >= 1000) return 2;
	else if (x >= 100) return 3;
	else if (x >= 10) return 4;
	else return 5;
}

int main(void) {
	int n, m, i, j, p[100003], y, b[100003], k;
	vector<P> v[100003];

	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> p[i] >> y;
		v[p[i]].push_back(P(y, i));
	}

	for (i = 1; i <= n; i++) {
		sort(v[i].begin(), v[i].end());
		for (j = 0; j < v[i].size(); j++) {
			b[v[i][j].second] = j + 1;
		}
	}

	for (i = 0; i < m; i++) {
		k = dn(p[i]);
		for (j = 0; j < k; j++) cout << 0;
		cout << p[i];
		k = dn(b[i]);
		for (j = 0; j < k; j++) cout << 0;
		cout << b[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#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<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<double> b(n);
  b[0] = (a[0]+a[1])/2.0;
  rep(i,n-2){
    b[i+1] = (b[i]+a[i+2])/2.0;
  }

  cout << b[n-2] << endl;
  
  return 0;
}


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

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

Measured memory_bytes: 256