akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vvpl=vector<vector<pl>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

ll PS(ll x) {
  ll c=1;
  rep(i,x) {
    c=c*2;
  }
  return c;
}


int main() {
ll N;
  cin >>N;
  ll K;
  cin >>K;
  
  vl p(N);
  
  rep(i,N) {
cin >>p.at(i);
  }

  sort(all(p));
  ll sum=0;
  
  rep(i,K) {
sum+=p.at(i);
  }
  
  
  cout<<sum<<endl;
}


  

Measured memory_bytes: 3608
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] a = new int[3];

        for(int i = 0; i < 3; i++){
            a[i] = s.nextInt();
        }

        Arrays.sort(a);

        System.out.println(a[0] + " " + a[1] + " " + a[2]);

    }

}

Measured memory_bytes: 17168
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();
    println!("{}",if n < 1000 { "ABC" } else { "ABD" });
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint N;
lint arr[200000];
lint pos[200000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
	}
	REP(i, N) {
		pos[arr[i] - 1] = i;
	}
	lint curr = pos[0], cnt = 1, max_cnt = 0;
	REP(i, N - 1) {
		if (curr < pos[i + 1]) {
			cnt++;
		}
		else {
			max_cnt = max(max_cnt, cnt);
			cnt = 1;
		}
		curr = pos[i + 1];
	}
	max_cnt = max(max_cnt, cnt);
	cout << N - max_cnt;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 998244353;
const int N = 2e5+5;
int a[N];
void solve(){
    int n;
    cin>>n;
    int mn = 1e9;
    int mx = 0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
        mx = max(mx,x);
        mn = min(mn,x);
    }
    assert(mx>=mn);
    if(mx-mn>1){
        cout<<"No"<<endl;
        return;
    }
    assert(mx<=mn+1);
    if(mn==mx){
        if(n==mx+1){
            cout<<"Yes"<<endl;
            return ;
        }
        if(n/mx>1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return ;
    }
    assert(mx==mn+1);
    if(a[mn]>mn){
        cout<<"No"<<endl;
        return ;
    }
    assert(a[mn]<=mn);
    assert(a[mn]<mx);
    if((n-a[mn])/(mx-a[mn])<=1){
        cout<<"No"<<endl;
        return ;
    }
    cout<<"Yes"<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N,A,B,C,D,E;
	cin >> N >> A >> B >> C >> D >> E;
	int cnt = min(A,min(B,min(C,min(D,E))));
	cout << (N + (cnt - 1)) / cnt + 4 << 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 q = sc.nextInt();
        String s = sc.next();
        char[] t = new char[q];
        char[] d = new char[q];
        for (int i = 0 ; i < q ; i++) {
            t[i] = sc.next().charAt(0);
            d[i] = sc.next().charAt(0);
        }
        int left = 0;
        int ng = n;
        int ok = -1;
        //残るゴーレムの一番左のインデックス
        while (Math.abs(ok  - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (isDropable(mid, s, t, d)) {
                ok = mid;
            } else {
                ng = mid;
            }
            left = ng;
        }

        int right = n - 1;
        ng = -1;
        ok = n;
        //残るゴーレムの一番右のインデックス
        while (Math.abs(ok - ng) > 1) {
            int mid = (ng + ok) / 2;
            if (isDropable(mid, s, t, d)) {
                ok = mid;
            } else {
                ng = mid;
            }
            right = ng;
        }

        System.out.println(Math.max(right - left + 1, 0));

     }
    //選択したゴーレムが落ちるかどうか判定
    static boolean isDropable(int i, String s, char[] t, char[] d) {
        for (int j = 0 ; j < t.length ; j++) {
            if (s.charAt(i) == t[j]) {
                if (d[j] == 'L') {
                    i--;
                } else {
                    i++;
                }
            }
            if (i < 0 || i >= s.length()) {
                return true;
            }
        }
        return false;
    }

}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 < i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

int main()
{
	string s;
	cin >> s;
	
	ll ans = 0;
	ll len = 0;

	foreach(c,s)
		switch(c)
		{
			case 'A':
			case 'C':
			case 'G':
			case 'T':
				len++;
				ans = max(len,ans);
				break;
			default:
				len = 0;
				break;
		}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var a, b string
	fmt.Scan(&a, &b)
	var k string
	for i := 0; i < n; i++ {
		k += fmt.Sprintf(string(a[i]))
		k += fmt.Sprintf(string(b[i]))
	}
	fmt.Println(k)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int i,w=0,l=0,k=0;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
    	if(s[i]=='o')
    	w++;
    	else if(s[i]=='x')
    	l++;
	}
	k=15-s.length();
	if((w+k)>=8)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;



int main()
{

    ll n,a;

    cin>>n;
    a=n/2+n%2;

    double d=(a*1.0)/(n*1.0);
    printf("%0.10lf\n",d);

    return 0;
}


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

bool p(int i){
  return (i / 10000 == i % 10 && (i / 1000 - i / 10000 * 10) == i % 100 / 10);
}

int main(){
  int n;
  cin >> n;
  vector<int> k(n);
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> k[i];
  }
  sort(k.begin(),k.end());
  for(int i = 0; i < n-1; i++){
    if(k[i] != k[i+1]) ans++;
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin>>N>>M;
    int P[M],Y[M];
    map<int,int> m;

    rep(i,M){
        cin>>P[i]>>Y[i];
        P[i]--;
        m[Y[i]]=i;
    }
    map<int,int> w;
    map<int,int> y;
    for(auto p:m){
        w[P[p.second]]++;
        y[p.first]= w[P[p.second]];
    }
    rep(i,M){
        string ans="";
        int cou=0;
        int t=P[i]+1;
        while(t>0){
            cou++;
            t/=10;
        }
        rep(j,6-cou){
            ans+="0";
        }
        ans+=to_string(P[i]+1);
        int r=y[Y[i]];
        cou=0;
        while(r>0){
            cou++;
            r/=10;
        }
        rep(j,6-cou){
            ans+="0";
        }
        ans+=to_string(y[Y[i]]);
        cout << ans << endl;
    }
    



}


Measured memory_bytes: 21760
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

constexpr lint mod=1e9+7;

/* pow */
//a^b mod p
int64_t modpow(int64_t a,int64_t b,int64_t p)
{
	if(b==0)return 1;
	int64_t ret=modpow(a,b/2,p);
	ret=(ret*ret)%p;
	if(b%2==1)
		ret=(a*ret)%p;
	return ret;
}

/* combination */
// nCr mod p
int64_t comb(int64_t n,int64_t r,int64_t p)
{
	int64_t ret=1;
	for(int64_t i=0;i<r;i++)
	{
		ret*=(n-i);
		ret%=p;
	}
	for(int64_t i=2;i<=r;i++)
	{
		ret*=modpow(i,p-2,p);
		ret%=p;
	}
	return ret;
}

int main()
{
	lint X,Y;

	cin >> X >> Y;
	
	lint ans=0;
	if((2*Y-X)%3==0)
	{
		lint a=(2*Y-X)/3;
		lint b=Y-2*a;
		if(a>=0 && b>=0)
			ans=comb(a+b,min(a,b),mod);
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
#define epsilon 1e-6
ll power(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=(res*x)%M;
        n/=2;
        x=(x*x)%M;
    }
    return res;
}
// ll sp[M6*10];
// void sieve(){
//     for(int i=2;i<M6*10;i++) sp[i]=i;
//     for(int i=2;i*i<M6*10;i++){
//         if(sp[i]!=i) continue;
//         for(int j=i*2;j<M6*10;j+=i) {
//             if(sp[j]==j) sp[j]=i;
//         }
//     }
// }
ll n,m,A[M5];
ld K[M5],C[M5];
bool same(ld a,ld b){
    return fabs(a-b)<epsilon;
}
int  main()
{   ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,l,r,a,b,c;
    //cin>>tc;
    while(t++<tc){
        //cout<<"Case #"<<t<<": ";
        cin>>a>>b>>c;
        cout<<max(c-a+b,0LL);
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int N = Integer.parseInt(line[0]);
        int Y = Integer.parseInt(line[1]);

        for(int x = 0;x <= N;x++){
            for(int y = 0;y <= N-x;y++){
                int z = N - x- y;

                if(z < 0){
                    continue;
                }
                
                int sum = 10000 * x + 5000 * y + 1000 * z;

                if(Y == sum){
                    System.out.println(x + " " + y + " " + z);
                    return;
                }
            }
        }

    System.out.println("-1 -1 -1");

    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> r(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    r[a-1] += 1;
    r[b-1] += 1;
  }

  for (int i = 0; i < n; i++) {
    cout << r[i] << endl;
  }
  
}


Measured memory_bytes: 3592
let r()=List.map int_of_string(Str.split(Str.regexp" ")(read_line()))open Array;;match r()with[n;m;l]->(let($)s t=let a=make_matrix s t 0in for i=0to s-1do let x=of_list(r())in for j=0to t-1do a.(i).(j)<-x.(j)done done;a in let a=n$m and b=m$l in for i=0to n-1do for j=0to l-1do let c=ref 0in for k=0to m-1do c:=!c+a.(i).(k)*b.(k).(j)done;Printf.printf(if j=0then"%d"else" %d")!c done;print_newline()done)|_->()

Measured memory_bytes: 4644
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN=2e5+7;
ll n,m,k,ans,a[MAXN],b[MAXN];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) cin>>a[i],a[i]+=a[i-1];
	for(int i=1;i<=m;i++) cin>>b[i],b[i]+=b[i-1];
/*
cout<<"@@@ "<<endl;
	for(int i=1;i<=n;i++) cout<<a[i]<<" ";
*/
	//ans=0x3f3f3f3f;
	for(int i=0;i<=n;i++)
	{
		if(a[i]<=k)
		{
			int pos=lower_bound(b,b+m+1,k-a[i])-b;
			while(b[pos]>k-a[i]||pos>m) pos--;

			//cout<<"@@@ "<<a[i]<<" "<<pos<<endl;
			ans=max(ans,(ll)i+pos);
		}
		else break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6716
#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, t[101], d[101], v[101];
int sp[40404];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> t[i];
		t[i] *= 2;
		d[i] = d[i-1]+t[i];
	}
	for(int i = 1; i <= n; i++){
		cin >> v[i];
		v[i] *= 2;
		fill(sp+d[i-1], sp+d[i], v[i]); //max
	}
	
	for(int i = 1; i <= n; i++){
		if(v[i] > v[i-1]){
			for(int j = d[i-1]; j < d[i]; j++){
				chmin(sp[j], v[i-1]+j-d[i-1]);
			}
		}
		if(v[i] > v[i+1]){
			for(int j = d[i+1]; j >= d[i]; j--){
				chmin(sp[j], v[i+1]+d[i+1]-j);
			}
		}
	}
	for(int i = 1; i < 40404; i++){
		chmin(sp[i], sp[i-1]+1);
	}
	for(int i = 40000; i > 0; i--){
		chmin(sp[i], sp[i+1]+1);
	}
	
	i64 ans = 0;
	for(int i = 1; i < 40404; i++){
		ans += sp[i];
		
	}
	printf("%.10f\n", ans/4.0);
}

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: 384
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <typeinfo>
using namespace std;
int main(){
	int n,c;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i*i<=n)c=i*i;
		else break;
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll     long long int
#define pb     push_back
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std ;
int main()
{
     fast;
     int t=1;
    // cin>>t;
     while(t--)
     {
       ll  n,c=0;
       ll i,j=1,k,l,m,result,a,b,d;
      cin>>n;
      ll t=100,ans=100,sum=0;
      while(n>t)
      {
          sum=t*1/100;
          ans+=sum;
          t=ans;
          c++;
      }
      cout<<c<<endl;


     }

     return 0;
}


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

int main() {
  vector<char>s(4);
  for(int i=0;i<4;i++){
    cin >> s.at(i);
  }
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  if(a-b-c-d==7) printf ("%d-%d-%d-%d=7\n",a,b,c,d);
  else if(a-b-c+d==7) printf ("%d-%d-%d+%d=7\n ",a,b,c,d);
  else if(a-b+c-d==7) printf ("%d-%d+%d-%d=7\n",a,b,c,d);
  else if(a-b+c+d==7) printf ("%d-%d+%d+%d=7\n",a,b,c,d);
  else if(a+b-c-d==7) printf ("%d+%d-%d-%d=7\n",a,b,c,d);
  else if(a+b-c+d==7) printf ("%d+%d-%d+%d=7\n",a,b,c,d);
  else if(a+b+c-d==7) printf ("%d+%d+%d-%d=7\n",a,b,c,d);
  else if(a+b+c+d==7) printf ("%d+%d+%d+%d=7\n",a,b,c,d);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
 ios::sync_with_stdio(false);

ll a;
cin>>a;

ll val=a+a*a+a*a*a;
cout<<val<<endl;
return 0;
}




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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;


unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 3001;

ll value[3][2] = {0};
ll ks1[5001] = {0};
ll ks2[26000001] = {0};

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> n;
    cin >> value[0][0] >> value[1][0] >> value[2][0];
    cin >> value[0][1] >> value[1][1] >> value[2][1];

    rep(c1,0,n+1){
        ks1[c1] = 0;
        rep(c2,0,3){
            if(value[c2][0] <= c1){
                ks1[c1] = max(ks1[c1], ks1[c1-value[c2][0]] + value[c2][1] - value[c2][0]);
            }
        }
       // ks1[c1] += c1;
        //cerr << ks1[c1] << "\n";
    }
    m = ks1[n]+n;
    rep(c1,0,m+1){
        ks2[c1] = 0;
        rep(c2,0,3){
            if(value[c2][1] <= c1){
                ks2[c1] = max(ks2[c1], ks2[c1-value[c2][1]] + value[c2][0] - value[c2][1]);
            }
        }
       // ks2[c1] += c1;
    }
    cout << m+ks2[m] << "\n";

    return 0;
}


Measured memory_bytes: 196864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
int main() {
	int n;

	cin >>n;
	vector<int>v(n);
	rep(i,n){
		cin >> v[i];
	}
	vector<int>vm(n);
	vm[0]=v[0];
	for(int i=1;i<n;i++){
		vm[i]=min(v[i],vm[i-1]);
	}
	int ans =0;
	rep(i,n){
		if(v[i]==vm[i])ans++;
	}
	cout << ans <<endl;
	return 0;
}


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

int main()
{
	string s;
	while (cin >> s) {
		if (s =="-")
			break;
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int n;
			cin >> n;
			string s2;
			for (int j = 0; j < n; j++) {
				s2 += s[j];
			}
			s.erase(s.begin() , s.begin() + n);
			s = s + s2;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>

using namespace std;

int dp[(int)1e5 + 1];
int arr[(int)1e5 + 1];

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

	int n; cin >> n;

	for(int i= 0; i < n; i++) cin >> arr[i];

	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);

	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]));
	}

	cout << dp[n-1] << '\n'; 

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,ans=INF;
char s[200010];
bool flg;
int f[200010];
int main(){
	cin>>n;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)f[i]=f[i-1]+(s[i]=='.');
	for(int i=0;i<=n;i++){
		ans=min(ans,(i-f[i])+(f[n]-f[i]));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1280
{-# LANGUAGE BangPatterns #-}


import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import System.IO

patties :: Int -> Int
patties level = bit (level+1) - 1

layers :: Int -> Int
layers level = bit (level+2) - 3

-- eat l n
--  eats n layers from l-level burger
--  and returns numpatties
eat :: Int -> Int -> Int
eat 0 0 = 0
eat 0 _ = 1
eat lv lay
  | lay <= 1 = 0
  | lay < 1 + layer_nm1 = eat (lv-1) (lay-1)
  | lay <= 1 + layer_nm1 + 1 = patties (lv-1) + lay - (1 + layer_nm1)
  | otherwise = patties (lv-1) + 1 + eat (lv-1) (lay - (1 + layer_nm1 + 1))
  where
    layer_nm1 = layers (lv-1)

main :: IO ()
main = do
  [n,x] <- map read . words <$> getLine
  print $ eat n x


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;


const int MAX_N = 1 << 17;

// [1, n]
// BIT is initialized by zeros
// !!initializw the size ""n""!!
int bit[MAX_N + 1], n, q;

// get sum in [1, i]
// sum{[i, j]} = sum{[1, j]} - sum{[1, i-1]}
int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

// add x to bit[i]
void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    cin >> n >> q;
    rep(i, q) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c) {
            cout << sum(y) - sum(x - 1) << endl;
        } else {
            add(x, y);
        }
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long
#define foi(n) for(ll i=0;i<n;i++)
using namespace std;
int main(){
 
  double d,t,s;
  cin>>d>>t>>s;
  if((d/s)<=t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

ll f(ll n){
  switch (n%4)
  {
  case 0:
    return n;
    break;
  case 1:
    return 1;
    break;
  case 2:
    return n^1;
    break;
  case 3:
    return 0;
    break;
  }
  return 0;
}

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

  cout << (f(b) ^ f(a-1)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){return powm(a,m-2,m);}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,o,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>n;
ll ar[n];
ll maxi=-inf;
for(i=0;i<n;i++)
{
  cin>>ar[i];
  if(ar[i]<maxi)
  {
    sum+=maxi-ar[i];
    ar[i]=maxi;
  }
  maxi=max(maxi,ar[i]);
}
cout<<sum;
}


Measured memory_bytes: 5208
#include <stdio.h>

int get_gcd(int a, int b)
{
	int mod = a % b;
	return mod == 0 ? b : get_gcd(b, mod);
}

int main() {
	int a, b, gcd;
	while (scanf("%d%d", &a, &b) != EOF)
	{
		gcd = get_gcd(a,b);
		printf("%d %d\n", gcd, a / gcd * b);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int kN = 1e3 + 10;
const int kInf = 1e9 + 7;
typedef pair<int, int> pii;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
#define F first
#define S second

int n, m;
char c[kN][kN];

bool ok(int x, int y) {
	return x >= 0 && x < n && y >= 0 && y < m && c[x][y] == '.';
}

using P = tuple<int, int, int>;
//struct P {
//	int d;
//	pii p;
//	bool operator < (const P &b) const {
//		return d < b.d;
//	}
//};

bool vis[kN][kN];
int dis[kN][kN];
int main() {
	scanf("%d%d", &n, &m);
	int x[2], y[2];
	for(int i = 0; i < 2; i++) scanf("%d%d", &x[i], &y[i]);
	x[0]--, y[0]--, x[1]--, y[1]--;
	for(int i = 0; i < n; i++) scanf("%s", c[i]);

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) dis[i][j] = kInf;
	}
	priority_queue<P, vector<P>, greater<P>> pq;
	dis[x[0]][y[0]] = 0;
	pq.emplace(0, x[0], y[0]);
	while(!pq.empty()) {
		auto t = pq.top(); pq.pop();
		int d = get<0>(t);
		int xx = get<1>(t), yy = get<2>(t);
		if(vis[xx][yy]) continue;
		vis[xx][yy] = 1;
		for(int i = 0; i < 4; i++) {
			int x = xx + dx[i], y = yy + dy[i];
			if(!ok(x, y)) continue;
			if(dis[x][y] > d) {
				dis[x][y] = d;
				pq.emplace(d, x, y);
			}
		}

		for(int i = -2; i <= 2; i++) {
			for(int j = -2; j <= 2; j++) {
				int x = xx + i, y = yy + j;
				if(!ok(x, y)) continue;
				if(i == 0 && j == 0) continue;

				if(dis[x][y] > d + 1) {
					dis[x][y] = d + 1;
					pq.emplace(d + 1, x, y);
				}
			}
		}
	}

	//for(int i = 0; i < n; i++) {
	//	for(int j = 0; j < m; j++) {
	//		printf("%d ", vis[i][j]); 
	//	}
	//	puts("");
	//}
	if(!vis[x[1]][y[1]]) puts("-1");
	else printf("%d\n", dis[x[1]][y[1]]);
	return 0;
}


Measured memory_bytes: 9776
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    K=I()
    L=[]
    import queue
    
    
    q=queue.Queue()
    for i in range(1,10):
        q.put(i)
        
    dx=[-1,0,1]
        
        
    while len(L)!=K:
        a=q.get()
        L.append(a)
        res=a%10
        for i in range(3):
            c=dx[i]
            res2=res+c
            if res2!=-1 and res2!=10:
                new=a*10+res2
                q.put(new)
                
    print(L[-1])
                

main()


Measured memory_bytes: 56532
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> as;

string s;
map<string,int> len;
map<as,int> arr;

void array_name(size_t &p, string &res){
  while(p<s.size() && isalpha(s[p]))res += s[p++];
}

int number(size_t &p){
  int res = 0;
  while(p<s.size() && isdigit(s[p]))res = res*10 + (int)(s[p++]-'0');
  return res;
}

int expression(size_t &p){
  if(isdigit(s[p]))return number(p);
  string s; array_name(p,s);
  int id = expression(++p);
  p++;
  if(id<0)return -1;
  if(id >= len[s])return -1;
  if(arr.count(as(s,id)) == 0)return -1;
  return arr[as(s,id)];
}

int assignment(size_t &p){
  string s; array_name(p,s);
  int id = expression(++p);
  p += 2;
  int x = expression(p);
  if(id<0 || x<0)return -1;
  if(id >= len[s])return -1;
  arr[as(s,id)] = x;
  return x;
}

int declaration(size_t &p){
  string s; array_name(p,s);
  int l = number(++p);
  len[s] = l;
  return 1;
}

int statement(void){
  size_t p = 0;
  if(s.find("=") == string::npos)return declaration(p);
  return assignment(p);
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  for(;;){
    len.clear(); arr.clear();

    int cnt = 0, bug = 0;
    cin >> s;
    while(s != "."){
      int res = statement();
      
      cin >> s; cnt++;
      if(res<0 && bug==0)bug = cnt;
    }
    if(cnt==0)break;
    cout << bug << endl;
  }
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	int a = s[0] - '0',b = s[1] - '0',c = s[2] - '0',d = s[3] - '0';
	if(a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if(a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	else if(a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if(a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if(a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	else if(a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	else if(a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else if(a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# python template for atcoder1
import re
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    s1 = input()[:-1]
    if s1 == ".":
        exit()
    else:
        s2 = input()[:-1]

    s1_split = s1.split('"')
    s2_split = s2.split('"')
    diff_word = []
    ans = "DIFFERENT"
    for a, b in zip(s1_split, s2_split):
        if a == b:
            continue
        else:
            diff_word.append(a)
    if len(s1_split) == len(s2_split):
        if len(diff_word) == 0:
            ans = "IDENTICAL"
        elif len(diff_word) == 1:
            pattern = '\"(.*?)\"'
            reg = re.compile(pattern)
            str_const = reg.findall(s1)
            if diff_word[0] in str_const:
                ans = "CLOSE"
    print(ans)


while True:
    solve()



Measured memory_bytes: 6552
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2010;
#define ll long long
#define int ll
const int mo=1e9+7;
struct po
{
	int x,y,l;
}a[MAXN];
bool cmp(po a,po b){return a.l<b.l;}
int n,m,tmp,x;
int f[MAXN];
int find(int x) {return x==f[x]?x:f[x]=find(f[x]);}
int kruskal(int now)
{
	int res=0;
	for(int i=1;i<=n;i++) f[i]=i;
	if(now) {res+=a[now].l;f[a[now].x]=a[now].y;}
	for(int i=1;i<=m;i++){
		int r1=find(a[i].x),r2=find(a[i].y);
		if(r1==r2) continue;
		res+=a[i].l;
		f[r1]=r2;
	}
	return res;
}
inline int power(int x,int k)
{
	int cnt=1;
	while(k){
		if(k&1) cnt=cnt*x%mo;
		k>>=1;
		x=x*x%mo;
	}
	return cnt;
}
int val,cnt1,cnt2;
int ans;
main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=m;i++) cin>>a[i].x>>a[i].y>>a[i].l;
	sort(a+1,a+m+1,cmp);
	tmp=kruskal(0);
	if(tmp>x){
		cout<<0;
		return 0;
	}
	if(tmp==x){
		for(int i=1;i<=m;i++){
			val=kruskal(i);
			if(val==x) cnt1++;
			else cnt2++;
		}
		ans=((power(2,cnt1)-2)*power(2,cnt2)%mo+mo)%mo;
	} else {
		for(int i=1;i<=m;i++){
			val=kruskal(i);
			if(val==x) cnt1++;
			else if(val>x) cnt2++;
		}
		ans=(2*(power(2,cnt1)-1)%mo*power(2,cnt2)%mo+mo)%mo;
	}
	cout<<ans;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
const long MOD=1e9+7;

template<class T> T lcm(T a,T b){
	return a/__gcd(a,b)*b;
}

int main(){
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double const pi=3.141592653589793;
	double asita,bsita;
	asita=h*30+m*0.5;
	bsita=m*6;
	asita=asita*pi/180;
	bsita=bsita*pi/180;
	double ax,ay,bx,by;
	ax=cos(asita)*a;ay=sin(asita)*a;
	bx=cos(bsita)*b;by=sin(bsita)*b;
	cout << fixed << setprecision(15) << sqrt(pow(ax-bx,2)+pow(ay-by,2));	
	return 0;
}


Measured memory_bytes: 4100
s = input()
s = s[:-1]
while True:
    num = len(s)
#    print(s,s[:num//2],s[num//2:])
    if num%2 == 0 and s[:num//2] == s[num//2:]:
        print(len(s))
        exit()
    else:
        s = s[:-1]

Measured memory_bytes: 2940
#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";
    else if(A+B<C+D)
        cout<<"Right";
        else
            cout<<"Balanced";

        return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

int main() {fio;
	int n, l;
	cin >> n;
	ll ans = 0, sm = 0;
	while(n--) {
		int u;
		cin >> u;
		if(u == 0)  {
			ans += sm / 2;
			sm = 0;
		}
		sm += u;
	}
	ans += sm / 2;
	cout << ans << endl;
	return 0;
}

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

int sumnum(int num)
{
    int dig = 0;
    int sum = 0;
    while (num)
    {
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    return sum;
}

int main()
{

    int N;
    cin >> N;
    int fx = sumnum(N);
    cout << (N % fx == 0 ? "Yes" : "No");
}


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

bool is_in_arr(int arr[], int len, int x){
  for(int i=0; i<len; i++){
    if(x == arr[i])
      return true;
  }
  return false;
}

int main(){
  int x, n;
  int arr[101];
  while(cin >> x >> n){
    for(int i=0; i<n; i++){
      cin >> arr[i];
    }
    int x_n = x, dif_n = 0;
    while(is_in_arr(arr, n, x_n)){
      x_n -= 1;
      dif_n = abs(x-x_n);
    }
    int x_p = x, dif_p = 0;
    while(is_in_arr(arr, n, x_p)){
      x_p += 1;
      dif_p = abs(x-x_p);
    }
    if(dif_p < dif_n){
      cout << x_p << endl;
    }
    else{
      cout << x_n << endl;
    }
  }
}

Measured memory_bytes: 3148
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

struct DepthFirstSearch {
    n: usize,
    k: usize,
    h: Vec<i32>,
    memo: Vec<i32>,
}
impl DepthFirstSearch {
    fn rec(&mut self, k: usize) -> i32 {
        if self.memo[k] != -1 {
            return self.memo[k];
        }

        let res = if k + 1 == self.n {
            0
        } else {
            let mut vals: Vec<i32> = Vec::new();
            for i in 1..(self.k + 1) {
                if k + i == self.n {
                    break;
                }
                let val = self.rec(k + i) + (self.h[k + i] - self.h[k]).abs();
                vals.push(val);
            }
            vals.sort_by_key(|&x| x);
            vals[0]
        };
        self.memo[k] = res;
        res
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i32; n],
    }
    let memo: Vec<i32> = vec![-1; n];
    let mut dfs = DepthFirstSearch{ n: n, k:k, h: h, memo: memo };
    println!("{}", dfs.rec(0));
} 


Measured memory_bytes: 27772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");

		int A = Integer.parseInt(tmp[0]);
		int P = Integer.parseInt(tmp[1]);

		int k = A*3 + P;

		System.out.println(k/2);
	}
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;

	int current, maxLength;
	current = maxLength = 0;

	for (int i = 0; (size_t) i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			current++;
			if (maxLength < current) {
				maxLength = current;
			}
		} else {
			current = 0;
		}
	}

	cout << maxLength << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int N;
    static int K;
    static int Q;
    static int[] V;
    // static int[] k;
    // static Condition[] st;
    // static int[] p;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        R[] arr = new R[N];
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            int p = Integer.parseInt(sc.next());
            arr[i] = new R(i+1, s, p);
        }
        Arrays.sort(arr);
        for (int i = 0; i < N; i++) {
            System.out.println(arr[i].i);
        }
    }
    static class R implements Comparable<R> {
        int i;
        int p;
        String s;
        public R (int i, String s, int p) {
            this.i = i;
            this.s = s;
            this.p = p;
        }
        @Override
        public int compareTo(R o) {
            if (this.s.equals(o.s)) {
                return o.p - this.p;
            } else {
                return this.s.compareTo(o.s);
            }
        }
    }
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a > c) {
		swap(a, c);
	}
	if (b > c) {
		swap(b, c);
	}
	if (a > b) {
		swap(a, b);
	}
	cout << a << ' ' << b << ' ' << c << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
    cin>>n;
    if(n%2==0)
    {
    cout<<0.5000000000;}
  else
  {
    double ma=ceil((double)n/2)/n;
    printf("%.8f",ma);
  }
      
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = 0;
		
		for(int i=1 ; i<=a ; i++) {
			if(i > b) {
				e += d;
			}
			else {
				e += c;
			}
		}
		
		System.out.println(e);
	}
}


Measured memory_bytes: 21716
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

ans = 0
for i in range(61):
  c0 = 0
  c1 = 0
  for a in A:
    if (a>>i)&1 == 1:
      c1 += 1
    else:
      c0 += 1
  #print(c1,c0)
  ans += ((c0*c1)<<i)
  ans %= MOD
print(ans)


Measured memory_bytes: 122936
#include <iostream>
#include <algorithm>
#include <ctype.h>
using namespace std;

int main(){
	int n,t;
	string type,s,a,b,c;
	cin >> n;
	while(n--){
		cin >> type >> s;
		reverse(type.begin(),type.end());
		for(int i=0;i<type.length();i++){
			switch(type[i]){
			case 'J':
				rotate(s.begin(),s.begin()+s.length()-1,s.end());
				break;
			case 'C':
				rotate(s.begin(),s.begin()+1,s.end());
				break;
			case 'E':
				t = s.length();
				a = s.substr(0,t/2);
				b = s.substr(t/2+t%2,t/2);
				c = "";if(t%2)c = s[t/2];
				s = b+c+a;
				break;
			case 'A':
				reverse(s.begin(),s.end());
				break;
			case 'P':
				for(int j=0;j<s.length();j++){
					if( isdigit(s[j]) ){
						s[j] = '0'+(s[j]-'0'+9)%10;
					}
				}
				break;
			case 'M':
				for(int j=0;j<s.length();j++){
					if( isdigit(s[j]) ){
						s[j] = '0'+(s[j]-'0'+1)%10;
					}
				}
				break;
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 0
s = list(input())
l = len(s)//2

l2 = 0
ans = 0
#print(s)
for i in range(1,len(s)//2):
  s2 = s[0:-2*i]
  #print(s2)
  l2 = len(s2)//2
  if s2[0:l2]==s2[l2:]:
    ans = len(s2)
    break

print (ans)   

Measured memory_bytes: 3060
#include<iostream>
#include <stdio.h>
using namespace std;
int main(){
	int a, b, d, r;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	double f;
	f = 1.0*a / b;
	cout << d << " " << r << " ";
	printf("%.8lf\n", f);
	return 0;
}

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

#define ll long long int

using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (auto & a : A) cin >> a;

    ll res = 0;
    for (ll i = 0; i < n; ++i) {
        if ((i+1)%2 == 1 && A[i]%2 == 1) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int b[maxn];
int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	if(x == 1 || x == 2 * n - 1) 
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i = 1; i <= 2 * n - 1; ++i) b[i] = i;
	if(x > n)
	{
		b[n] = x;
		b[n + 1] = x + 1;
		int cnt = n;
		for(int i = n + 2; i <= 2 * n - 1; ++i)
		{
			while(cnt == x || cnt == x + 1) ++cnt;
			b[i] = cnt;
			++cnt;
		}
	}
	else
	{
		b[n] = x;
		b[n - 1] = x - 1;
		int cnt = 1;
		for(int i = 1; i <= n - 2; ++i)
		{
			while(cnt == x || cnt == x - 1) ++cnt;
			b[i] = cnt;
			++cnt;
		}
	}
	for(int i = 1; i <= 2 * n - 1; ++i) printf("%d ", b[i]);
	puts("");
	return 0;
} 

Measured memory_bytes: 4468