akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) cnt++;
        }
        ans += (cnt == 8);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
	int n;cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				sum+=(gcd(gcd(i,j),k));
			}
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

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

    long long int t=0;
    for(int i=0;i<m;i++){
        t += b[i];
    }

    int j=m;
    int ans = 0;

    for(int i=0;i<n+1;i++){
        while(j>0 && t>k){
            j--;
            t -= b[j];
        }
        if(t>k){
            break;
        }
        ans = max(ans,i+j);
        if(i==n){
            break;
        }
        t += a[i];
    }
    cout << ans << endl;
    

}


Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


int N;
vector<vector<int>> edge;

pll dfs(ll u,ll p){
  pll ret={0,u};
  for(auto &v:edge[u]){
    if(v==p){continue;}
    ret=max(ret,dfs(v,u));
  }
  if((int)edge[u].size()==2){ret.F++;}
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  edge.resize(N);
  for(int i=1;i<N;i++){
    int p,q;
    cin>>p>>q;
    p--; q--;
    edge[p].push_back(q);
    edge[q].push_back(p);
  }
  int ans=0;
  for(auto &I:edge){
    if((int)I.size()==1){ans++;}
  }
  int s=dfs(0,-1).S;
  ans+=dfs(s,-1).F;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
bool gu(string s) {
    int n = s.size();
    string x, y;
    for(int i = 0; i < n/2; i++) x += s.at(i);
    for(int i = n/2; i < n; i++) y += s.at(i);
    return x==y;
}
int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n/2; i++) {
        s.pop_back();
        s.pop_back();
        if(gu(s)) {
            ans = n-(i+1)*2;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	Scanner sc =new Scanner(System.in);
	
	int kingaku;
	int[] goukei = new int[4];
	int x;

	public void syurui(){
		for(x=0;x<=3;x++){
			int syurui = sc.nextInt();
			int maisuu = sc.nextInt();
		
		
			switch(syurui){
				case 1: kingaku = 6000; break;
				case 2: kingaku = 4000; break;
				case 3: kingaku = 3000; break;
				case 4: kingaku = 2000; break;
			}
			goukei[x] = kingaku * maisuu;
		}
	}
	public void hyouji(){
		for(x=0;x<=3;x++){
			System.out.println(goukei[x]);
		}
	}


	public static void main(String[] args) {
		Main hai = new Main();
		hai.syurui();
		hai.hyouji();

	}

}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  ll N;
  cin >> N;

  ll h[N];
  for (ll i = 0; i < N; i++) {
    cin >> h[i];
  }

  ll dp[N + 1];
  for (ll i = 0; i < N + 1; i++) {
    dp[i] = LLONG_MAX;
  }

  dp[0] = 0;
  for (ll i = 1; i < N; i++) {
    dp[i] = abs(h[i] - h[i - 1]) + dp[i - 1];

    if (1 < i) {
      dp[i] = min(dp[i], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }

    // cout << dp[i] << endl;
  }

  cout << dp[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(){
	int n;
	cin >> n;
	int a[n];
	unordered_map<int, int> freq;
	rep(i, n) {
		cin >> a[i];
		freq[a[i]]++;
	}
	sort(a, a + n);
	int ans = 0;
	set<int> vis;
	rep(j, n){
		bool check = true;
		if (freq[a[j]]!=1){
			check = false;
		}
		for(int i = 1; i <= sqrt(a[j]); i++){
			if (check==false){
				break;
			}
			if (a[j]%i == 0){
				if (vis.find(i) != vis.end() || vis.find(a[j]/i) != vis.end()){
					check = false;
					break;
				}
			}
		}
		if (check) ans++;
		vis.insert(a[j]);
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int q;
    cin >> q;
    rep(i, q) {
        ll k;
        cin >> k;

        auto it = lower_bound(a.begin(), a.end(), k);
        if (it == a.end()) {
            cout << n << endl;
        } else {
            cout << distance(a.begin(), it) << endl;
        }
    }

}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll a;
	cin>>a;
	if(a<=999)
	{
		cout<<"ABC"<<Endl;
	}
	else cout<<"ABD"<<Endl;
	return 0;
} 


Measured memory_bytes: 3596
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main (){ 
    ll n ;
    cin >> n ;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    vector<int> s;
    s.assign(x.begin(), x.end());
    sort(s.begin(), s.end(), less<int>());
 
    rep(i, n) {
    int l = s[n / 2 - 1];
    int r = s[n / 2];
    int mid = x[i] <= l ? r : l;
    cout << mid << endl;
  }

}
    

 


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}

int main(void)
{
    ll n;
    cin >> n;
    vector<map<char,ll>> v(n);
    map<char,ll> mp;
    rep(i,n){
        string s;
        cin >> s;
        rep(j,s.size()) v[i][s[j]]++;
    }
    for(char c='a'; c<='z'; c++){
        ll mini = INF;
        rep(i,n) mini = min(mini, v[i][c]);
        mp[c] = mini;
    }
    string ans;
    for(auto c:mp){
        if(c.second > 0){
            rep(i,c.second) ans += c.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    int N;
    int h[101];
    cin >> N;
    for (int i; i < N; i++)
    {
        cin >> h[i];
    }
    int ans = 0;
    int t = 0;
    for (int i = 0; i < N; i++)
    {
        if (h[i] > t)
        {
            ans = ans + h[i] - t;
        }
        t = h[i];
    }
    cout << ans << endl;
    return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll M = 0;
ll ret = 0;
ll table[100005];
vector<ll> group;

ll fib(ll x) {
  if (table[x] != -1) {
    return table[x];
  } else if (x == 1 || x == 0) {
    table[x] = 1;
    return 1;
  } else {
    ll ans = fib(x-1) + fib(x-2);
    ans %= MOD;
    table[x] = ans;
    return ans;
  }
}

void input() {
  IN(N);
  IN(M);
  ll begin = 0;
  ll end;
  REP(i, M) {
    IN(end);
    group.pb(end - begin);
    begin = end + 1;
  }
  group.pb(N - begin + 1);

  REP(i, 100005) {
    table[i] = -1;
  }
}

void solve() {
  ret = 1;
  EACH(group.begin(), group.end()) {
    ll mem = *itr;
    if (mem == 0) {
      ret = 0;
      break;
    } else {
      ret *= fib(mem-1);
      ret %= MOD;
    }
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

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

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] g = new int[n];
        int[] g2 = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            if(i != 0) g[i] = gcd(g[i - 1], a[i]);
            else g[i] = a[i];
        }
        g2[n - 1] = a[n - 1];
        for(int i = n - 2; i >= 0; i--){
            g2[i] = gcd(g2[i + 1], a[i]);
        }
//        for(int i = 0; i < n; i++){
//            System.out.print(g2[i] + " ");
//        }
        int ans = Math.max(g2[1], g[n - 2]);
        for(int i = 1; i < n - 1; i++){
            int to = gcd(g[i - 1], g2[i + 1]);
            ans = Math.max(ans, to);
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 51456
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main(void){
	
	int yen,k;
	yen = 700;

	string s;

	cin >> s;

	for (k = 0; k < 3; k++) {
		if (s[k] == 'o')yen += 100;
	}
	cout << yen << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using Graph = vector<vector<int>>;

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int N, K;
bool win[100005] = {false};
int a[105];

int main(){
    cin >> N >> K;
    rep(i,N) cin >> a[i];

    for( int res_stone = 1; res_stone <= K; ++res_stone){
        for( int i = 0; i < N; ++i){
            int after_stone = res_stone - a[i];
            if( after_stone < 0) continue;
            else{
                if( !win[after_stone] ){
                    win[res_stone] = true;
                    break;
                }
            }
        }
    }
    cout << (win[K] ? "First" : "Second");
    return 0;
}

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




int main(){
	int N;
	cin>>N;
	
	long long ans = 0;
	vector<int> A;
	vector<int> B;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		A.push_back(a);
		B.push_back(b);
	}
	if(A==B){
		cout<<0<<endl;
		return 0;
	}
	vector<int> x;
	for(int i=0;i<N;i++){
		if(A[i]<=B[i]){
			ans = (long long)ans+B[i];
		}
		else{
			x.push_back(B[i]);
		}
	}
	
	sort(x.begin(),x.end(),greater<int>());
	
	for(int i=0;i<x.size()-1;i++){
		ans=(long long)ans+x[i];
	}
	
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<double>x(n),y(n);
    for(int i=0; i < n; i++)cin >> x[i];
    for(int i=0; i < n; i++)cin >> y[i];
    double euclid=0, manh=0, th=0, cheby=0;
    for(int i=0; i < n; i++){
        manh += abs(x[i] - y[i]);
        euclid += pow(x[i] - y[i], 2);
        th += pow(abs(x[i] - y[i]), 3);
        cheby = max(cheby, abs(x[i] - y[i]));
    }
    cout << setprecision(12) << manh << endl;
    cout << setprecision(12) << sqrt(euclid) << endl;
    cout << setprecision(12) << cbrt(th) << endl;
    cout << setprecision(12) << cheby << endl;
    return 0;
}


Measured memory_bytes: 3476
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

K = len(bin(np.max(A))) - 2

ans = 0
mod = 10 ** 9 + 7
N %= mod

for i in range(K):
    bit = np.count_nonzero(A >> i & 1) % mod
    ans += 2 ** i * bit * (N - bit)
    ans %= mod
    
print(ans)

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,ans=0;
    cin >> n;
    for(int i=1;i<=n;i+=2){
        int res=0;
        rep(j,1,i+1){
            if(i%j==0) res++;
        }
        if(res==8) ans++;
    }
    cout << ans << "\n";
}

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

///////////////////////////
int main() {
  int n,a,cnt[100010]={0},ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    cnt[a]++;
  }
  for(int i=0;i<100000;i++){
    ans=max(ans,cnt[i]+cnt[i+1]+cnt[i+2]);
  }
  cout<<ans<<endl;
}
///////////////////////////



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

int main() 
{
    ll n;
    cin >> n;
    ll x;
    cin >> x;
    ll sum = 1;
    for (ll i=1; i<n; i++)
    {
        ll p;
        cin >> p;
        if (p<x)
            sum++;
        x = min(x,p);
    }
    cout << sum;
    return 0;
}

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

using namespace std;

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

	int len = (int)s.length();

	if (len % 2 == 1) {
		cout << "No";
		return 0;
	}

	len = len / 2;
	bool f = false;
	for (int i = 0; i < len; i++) {
		if (s[i] != s[i + len]) {
			f = true;
			break;
		}
	}

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

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

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

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    string ans = "Yay!";
    if (e - a > k) {
        ans = ":(";
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


N = int(input())
abc=[]
for _ in range(N-1):
    abc.append(tuple(map(int, input().split())))
Q, K = map(int, input().split())
xy=[]
for _ in range(Q):
    xy.append(tuple(map(int, input().split())))
#print(abc)
#print(xy)

G = [[] for _ in range(N+1)]
for el in abc:
    a,b,c = el
    G[a].append((b,c))
    G[b].append((a,c))
#print(G)

seen=[False]*(N+1)
distance=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for el in G[n]:
        if seen[el[0]] == False:
            distance[el[0]] = distance[n] + el[1]
            dfs(el[0])
dfs(K)
#print(distance)

for q in xy:
    print(distance[q[0]]+distance[q[1]])


Measured memory_bytes: 211972
n,x=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

a.sort()
s=0
if sum(a)==x:
    ans=n
elif sum(a)<x:
    ans=n-1
else:
    for i in range(n):
        if sum(a[:i+1])>x:
            ans=i
            break;
print(ans)

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

using namespace std;

const int N = 1e5, M = 1e6 + 6, OO = 0x3f3f3f3f;

int n, d, n1, n2;
string num, num1, num2;

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n ; ++i)
	{
		cin >> d;
		num1 += (d + '0');
	}
	for(int i = 0; i < n ; ++i)
	{
		cin >> d;
		num2 += (d + '0');
	}
	num = num1;
	sort(num.begin(), num.end());
	int i = 1;
	while(next_permutation(num.begin(), num.end()))
	{
		if(num == num1)
			n1 = i;
		if(num == num2)
			n2 = i;
		++i;
	}
	printf("%d\n", abs(n2 - n1));
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
int main()
{
	long long a,b,x;
	scanf("%lld%lld%lld",&a,&b,&x);
	long long ans=0;
	if(a%x==0)ans=a/x;
	else ans=a/x+1;
	printf("%lld\n",b/x-ans+1);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Program
{
    public static void Main(string[] args)
    {
        new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
        string[] a = ReadLine().Split(' ');
        var n = int.Parse(a[0]);
        var k = int.Parse(a[1]);
        string[] height = ReadLine().Split(' ');
        var count = 0;
        foreach (var item in height)
        {
            if (int.Parse(item) >= k)
                count++;
        }
        WriteLine(count);
        ReadKey();
    }
}

public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 1000000007;

ll getmin(ll l, ll r) {
	if (l == -1) return 0ll;

	vi vl, vr;
	while (l > 0) {
		vl.pb(l & 1);
		l >>= 1;
	}
	while (r > 0) {
		vr.pb(r & 1);
		r >>= 1;
	}
	while (vl.size() < vr.size()) {
		vl.pb(0);
	}
	int sz = vl.size();
	ll c = 0;
	for (int i = sz-1; i >= 0; --i) {
		if (vl[i] != vr[i]) {
			c = c * 2 + 1;
			c <<= i;
			break;
		} else {
			c = c * 2 + vl[i];
		}
	}
	return c;
}

int main() {
	int N; ll K;
	cin >> N >> K;
	vector<ll> X(N);
	rep(i, N) cin >> X[i];
	sort(ALL(X));

	map<vector<ll>, vector<pair<ll,ll>>> T;

	for (int t = 0; t <= 60; ++t) {
		vector<ll> cand = {-1};
		rep(i, N) {
			cand.pb(X[i] % (1ll << t));
		}
		sort(ALL(cand));
		rep(i, (int)cand.size()-1) {
			if (cand[i] != cand[i+1]) {
				ll l = cand[i], r = cand[i+1];
				ll opt = getmin(l, r);
				ll ope = __builtin_popcountll(opt) + t;
				if (ope > K) continue;
				auto nx = X;
				rep(j, N) {
					nx[j] = (X[j] - opt) >> t;
				}

				ll u = min(K - ope, nx[0]) - nx[0];
				ll d = -nx[0];

				for (int j = N-1; j >= 0; --j) {
					nx[j] -= nx[0];
				}

				T[nx].eb(d, u);
			}
		}
	}

	ll ans = 0;
	for (auto& t : T) {
		auto& vec = t.se;
		sort(ALL(vec));
		ll r = -TEN(18);

		rep(i, vec.size()) {
			if (vec[i].se <= r) {
				continue;
			}
			if (vec[i].fi > r) {
				ans += vec[i].se - vec[i].fi + 1;
			} else {
				ans += vec[i].se - r;
			}

			r = max(r, vec[i].se);
			ans %= MOD;
		}

		//cout << t.fi << ", " << t.se << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define inf (1<<29)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define MEMSET(a) memset(a,0,sizeof(a))
#define pb push_back
using namespace std;

int main(){
	int N;
	long long W;
	cin>>N>>W;
	int w,v,w1;
	vector<int> V[4];
	cin>>w1>>v;
	V[0].pb(v);
	rep(i,N-1){
		cin>>w>>v;
		V[w-w1].pb(v);
	}
	rep(i,4){
		sort(V[i].begin(),V[i].end());
		reverse(V[i].begin(),V[i].end());
		rep(j,(int)V[i].size()-1)V[i][j+1]+=V[i][j];
	}
	long long max=0;
	rep(i,V[0].size()+1){
		rep(j,V[1].size()+1){
			rep(k,V[2].size()+1){
				rep(l,V[3].size()+1){
					long long t=(long long)(i+j+k+l)*w1+j+2*k+3*l;
					long long r=0;
					if(i)r+=V[0][i-1];
					if(j)r+=V[1][j-1];
					if(k)r+=V[2][k-1];
					if(l)r+=V[3][l-1];
					if(t<=W&&r>max)max=r;
				}
			}
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
using namespace std;
typedef long long ll;
int main() {
    int x, y;
    while (1) {
        cin >> x >> y;
        if (!x && !y) break;
        if (x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		for (int i = 0; i < x.length; i++) {
			for (int j = 0; j < x[0].length; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int count = 0;
		for (int i = 0; i < x.length; i++) {
			for (int j = i + 1; j < x.length; j++) {
				if (i == j) {
					continue;
				}
				double len = 0.;
				for (int k = 0; k < x[0].length; k++) {
					len += Math.pow(x[i][k] - x[j][k], 2);
				}
				len = Math.sqrt(len);
				if (Math.abs(len - Math.round(len)) < 1E-8) {
					++count;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

#define pi M_PI

int main(void) {
  int a, b, c;
  double rad, d;
  double square, length, height;

  scanf("%d %d %d", &a, &b, &c);
  rad = pi * c / 180;

  square = sin(rad) * a * b / 2;
  height = square * 2 / a;
  d = sqrt(a * a + b * b - 2 * a * b * cos(rad));
  length = a + b + d;

  printf("%lf\n%lf\n%lf\n", square, length, height);

  return 0;
}



Measured memory_bytes: 2124
import math
n,l = map(int,input().split())
lists = []

for i in range(n):
    lists.append(l)
    l += 1

    c = 0
if 0 in lists:
    lists.remove(0)
    print(sum(lists))
else:
    for j in lists:
        if j > -1:
            c += 1           
    if c == len(lists):
        lists.remove(min(lists))
        print(sum(lists))
    else:
        lists.remove(max(lists))
        print(sum(lists))
    

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 300004;

i64 n;
i64 a[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s, t, u;
    i64 a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s == u) {
        cout << a - 1 << " " << b << endl;
    }
    else {
        cout << a << " " << b - 1 << endl;
    }

    return 0;
}

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

#define int long long
const int MOD = 1000000007LL;

signed main(){

    int n; cin >> n;
    vector<double> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    vector<vector<double> > dp(n + 1, vector<double> (n + 1, 0.0));
    dp[0][0] = 1.0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(dp[i][j] < 1e-18) continue;

            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double ans = 0.0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[n][i];
    }
    
    printf("%.12f\n", ans);

    return 0;
}

Measured memory_bytes: 70656
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,t;
    cin>>x>>t;
    cout<<max(0ll,x-t)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int a, b;
	cin >> a >> b;
	int x = 0;
	while (1) {

		if (int(x*1.08 - x) == a && int(x*1.1 - x) == b)break;
		if (x > 10001) {
			x = -1;
			break;
		}
		x++;
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int N,A[100000];
int main(){
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  long long sum=A[0],cnt=0;
  if(sum<=0){
    cnt+=1-sum;
    sum=1;
  }
  FOR(i,1,N){
    sum+=A[i];
    if(i%2==1){
      if(sum>=0){
        cnt+=sum+1;
        sum=-1;
      }
    }else{
      if(sum<=0){
        cnt+=1-sum;
        sum=1;
      }
    }
  }
  long long sum2=A[0],cnt2=0;
  if(sum2>=0){
    cnt2+=sum2+1;
    sum2=-1;
  }
  FOR(i,1,N){
    sum2+=A[i];
    if(i%2==1){
      if(sum2<=0){
        cnt2+=1-sum2;
        sum2=1;
      }
    }else{
      if(sum2>=0){
        cnt2+=sum2+1;
        sum2=-1;
      }
    }
  }
  cout<<min(cnt,cnt2)<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    vector<int> n(3);
    cin >> n[0] >> n[1] >> n[2];

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

    int count = 0;
    count += (n[2] - n[1]);
    n[0] += (n[2]-n[1]);
    count += (n[2]-n[0]) / 2;
    n[0] += ((n[2]-n[0]) / 2) * 2;
    if ((n[2]-n[0]) == 1) {
        count += 2;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.src", "r", stdin);
	string str = "";
	stack <int> R;

	while ( getline (cin, str )){
		int n;
		stringstream ss(str);
		ss >> n;
		if (n != 0){
			R.push(n);
		}else if (n == 0 && !R.empty()){
			cout << R.top() << endl;
			R.pop();
		} // end if
	} // end for

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yawn ios_base::sync_with_stdio(false); cin.tie(NULL);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
const int N = 150005;
int sz[N] , p[N];

void initialize(){
    iota(p , p + N , 0); // 0 1 2 3 .. N
    fill(sz , sz + N , 1);
}
double dis(int x1,int y1, int x2, int y2)
{
    return sqrt( (double)(x1-x2)*(x1-x2) + (double)(y1-y2)*(y1-y2) );
}
int FindParent(int u){
    return p[u] = (p[u] == u ? u : FindParent(p[u]));
}

void Union(int u , int v){
    u = FindParent(u);
    v = FindParent(v);

    if(u == v)return;

    if(sz[v] < sz[u])swap(u , v);

    p[u] = v;
    sz[v] += sz[u];
}
int main()
{
    yawn;
    int n,k;
    cin>>n>>k;
    if(k==1) {cout<<0; return 0;}
    cout<< (n-k+1)-1;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    int N, C, D[300001], Co[300001];
    cin >> N >> C;
    for (int i = 1; i <= C; i++) {
        for (int j = 1; j <= C; j++) {
            cin >> D[i*C + j];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cin >> Co[i*N + j];
        }
    }

    ll D0[31], D1[31], D2[31];

    for (int c = 1; c <= C; c++) {
        ll ds[3] = { 0, 0, 0 };

        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                int orig = Co[i * N + j];
                ll d = D[orig * C + c];
                ds[(i + j) % 3] += d;
            }
        }

        D0[c] = ds[0];
        D1[c] = ds[1];
        D2[c] = ds[2];
    }

    ll ddd = 99999999999999;
    for (int i = 1; i <= C; i++) {
        for (int j = 1; j <= C; j++) {
            if (i == j) { continue; }
            for (int k = 1; k <= C; k++) {
                if (i == k || j == k) { continue; }

                ddd = min(ddd, (ll)(D0[i] + D1[j] + D2[k]));
            }
        }
    }

    cout << ddd<< endl;
}

Measured memory_bytes: 4572
fn main(){
    let mut N = String::new();
    let mut ans = 1; 
    std::io::stdin().read_line(&mut N).expect("stdio fail");

    let N: u32= match N.trim().parse(){
        Ok(num) => num,
        Err(_)  => 1
    };

    ans = N / 3;
    println!("{}", &ans.to_string());
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    ll n,k;cin >> n >> k;
    for(int i=0; i<35; i++){
        ll big=pow(k,i+1);
        ll small=pow(k,i);
        if(small<=n&&big>n){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
xs, ys, xt, yt = map(int, input().split())

# root1
for _ in range(xs, xt):
    print('R', end='')
for _ in range(ys, yt):
    print('U', end='')

# root2
for _ in range(xt, xs, -1):
    print('L', end='')
for _ in range(yt, ys, -1):
    print('D', end='')

# root3
print('D', end='')
for _ in range(xs, xt+1):
    print('R', end='')
for _ in range(ys-1, yt):
    print('U', end='')
print('L', end='')

# root4
print('U', end='')
for _ in range(xt, xs-1, -1):
    print('L', end='')
for _ in range(yt+1, ys, -1):
    print('D', end='')
print('R', end='')

print('')

Measured memory_bytes: 51692
input = gets.chomp
n,l = input.split.collect{ |item| item.to_i}

result = 0
l.upto(n+l-1) do |i|
  result += i
end

if ((l+n-1) < 0)
 result -= (l+n-1)
elsif (1 <= l)
  result -= l
end

puts result

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N; cin>>N;
  ll ans;
  if(N%2==0) ans=N/2*(N-1);
  else ans=(N-1)/2*N;
  cout<<ans<<endl;
}

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

pair<int64_t,int> p[100005];
map<int,int> c;
map<int,int> w;
int main(){
    int n,k;
    cin >> n >> k;
    int t;
    int64_t d;
    int64_t whole=0;
    for(int i=0;i<n;i++){
        cin >> t >> d;
        p[i]=make_pair(d,t);
        if(w[t]==0)whole++;
        w[t]++;    
    }
    sort(p,p+n);
    int64_t ans=0;
    int64_t var=0;
    for(int i=0;i<k;i++){
        ans+=p[n-1-i].first;
        c[p[n-1-i].second]++;
        if(c[p[n-1-i].second]==1)var++;
    }
    ans+=var*var;
    int loop=min(k-var,whole-var);
    if(loop==0)cout << ans <<endl;
    else{
        vector<int64_t> L;
        vector<int64_t> S;
        int j=0;
        for(int i=0;i<k;i++){
            if(c[p[n-k+i].second]>1){
                L.push_back(p[n-k+i].first);
                c[p[n-k+i].second]--;
                j++;
            }
            if(j==loop)break;
        }
        loop=min(j,loop);
        j=0;
        for(int i=0;i<n-k;i++){
            if(c[p[n-k-1-i].second]==0){
                S.push_back(p[n-k-1-i].first);
                c[p[n-k-1-i].second]++;
                j++;
            }
            if(j==loop)break;
        }
        loop=min(j,loop);
        int64_t neo=ans;
        int64_t tmp=0;
        for(int i=1;i<loop+1;i++){
            tmp+=(S.at(i-1)-L.at(i-1));
            neo=max(neo,ans+tmp+2*var*i+i*i);
        }
        cout << neo << endl;
    }
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String N = scan.nextLine();
    String str = "abcdefghijklnmopqrstuvwxyz";
    int x =  str.indexOf(N);
    System.out.println(str.charAt(x + 1));

  }
}


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

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> V(N);
    rep(i, N) cin >> V[i];

    rep(A, min(N, K) + 1) {
        rep(B, min(N, K) - A + 1) {
            vector<int> AB = V;
            AB.erase(AB.begin() + A, AB.end() - B);
            sort(AB.begin(), AB.end());
            rep(i, K - A - B) {
                AB[i] = max(0, AB[i]);
            }
            ans = max(ans, accumulate(AB.begin(), AB.end(), 0));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,b,a;
  cin >> n;
  a=0;
  for(int i=0;i<n;i++){
    a++;
  if(0<a&&a<10)
    b++;
  if(99<a&&a<1000)
    b++;
    if(9999<a&&a<100000)
    b++;
 
  }
  cout << b << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	var s string
	if scanner.Scan() {
		s = scanner.Text()
	}
	slice := strings.Split(s, " ")
	tT, _ := strconv.Atoi(slice[0])
	tA, _ := strconv.Atoi(slice[1])
	aT, _ := strconv.Atoi(slice[2])
	aA, _ := strconv.Atoi(slice[3])

	for {
		aT = aT - tA
		if aT <= 0 {
			fmt.Println("Yes")
			break
		}
		tT = tT - aA
		if tT <= 0 {
			fmt.Println("No")
			break
		}
	}
}


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

int main() {
    string s;
    int q;

    cin >> s >> q;

    bool inv = false;
    string head, tail; 
    rep(i, q) {
        static int t;
        cin >> t;
        if (t == 1) inv ^= 1;
        else {
            static int f;
            static char c;
            cin >> f >> c;
            if (f == 1 ^ inv) head += c;
            else tail += c;
        }
    }

    string ans;
    reverse(head.begin(), head.end());
    ans = head + s + tail;
    if (inv) reverse(ans.begin(), ans.end());

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1348
N=int(input())
H=list(map(int,input().split()))
H=H[::-1]
M=[0 for i in range(N)]

for i in range(N-1):
  if H[i]<=H[i+1]:
    if i>0:
      M[i]=M[i-1]+1
    else:
      M[i]=1
  else:
    M[i]=0
#print(H)
#print(M)
print(max(M))

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) { return i /2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }

int main() {
    int H, i, A[MAX+1];
    
    cin >> H;
    for (i = 1; i<=H; i++) cin >> A[i];

    for (i = 1; i <= H; i++) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3116