akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    
    string s;cin>>s;
    rep(i,0,2)cout<<s[i];
    
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  ll n, w;
  cin >> n >> w;
  ll weight[n+1], value[n+1];
  rep(i,n){
    cin >> weight[i+1] >> value[i+1];
  }

  vec2ll dp;
  dp.resize(n+1, vector<ll>(100010));
  rep(i,100010){
    dp[0][i]=1e10;
  }
  rep(i,n+1){
    dp[i][0]=0;
  }

  // dp[i][j]
  // value >= j tonaru omosa no minimum
  // i: choose goods from 1, 2, ..., i
  // j: value

  ll ans=0;
  REP(i,1,n+1){
    //prt2("phase: ", i);
    rep(j,100010){
      if(j-value[i]>-1){
        dp[i][j]=min(dp[i-1][j], dp[i-1][j-value[i]]+weight[i]);
        //prt("1");
      } else {
        dp[i][j]=dp[i-1][j];
        //prt("2");
      }
      if(dp[i][j]<=w && ans<j){
        ans=j;
      }
    }
  }
/*
  rep(i,n+1){
    rep(j,7){
      cout << dp[i][j] << " ";
    }
    cout << "\n";
  }
*/

  prt(ans);
}

/* test case
3 8
3 1
4 2
5 3

==========DP TABLE==========
value-> 0  1   2   3   4   5   6
-----------------------------------
        0 inf inf inf inf inf inf
        0  3  inf inf inf inf inf
        0  3   4   7  inf inf inf
        0  3   4   5   8   9   12

w = 8 ---> ans = 4
*/


Measured memory_bytes: 80256
import java.util.Scanner

object Main {

  def gcd(a: Int, b: Int): Int = {
    if (b == 0) (a)
    else if (a < b) (gcd(b, a))
    else (gcd(b, a % b))
  }

  def solve(sc: => Scanner): Unit = {
    val N, K = sc.nextInt()
    val D = Array.fill[Int](N)(sc.nextInt)
    if (D.max >= K && K % (D.foldLeft(0)((a, b) => (if (a == 0) (b) else (gcd(a, b))))) == 0) (
      println("POSSIBLE")
      ) else (
      println("IMPOSSIBLE")
      )
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 51448
//2017-7-28 21:13
//2017-7-28 21:38
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
 
struct node{
	LL a, b, c;
	bool operator <(const node &A) const{
		return (a-b) < A.a - A.b;
	}
}box[MaxN + 5];
 
int n, x, y, z;
LL tot, ans;
priority_queue<LL, vector<LL>, greater<LL> > q;
LL lef[MaxN + 5];
 
int main(){
	scanf("%d %d %d", &x, &y, &z);
	n = x + y + z;
	for(int i = 1; i <= n; i++){
		scanf("%lld %lld %lld", &box[i].a, &box[i].b, &box[i].c);
		tot += box[i].c;
	}
	sort(box + 1, box + 1 + n);
	LL ans = 0, sum = 0;
	for(int i = 1; i <= y; i++){
		sum += box[i].b - box[i].c;
		q.push(box[i].b - box[i].c);
	}
	for(int i = y + 1; i <= n - x + 1; i++){
		lef[i] = sum;
		sum += box[i].b - box[i].c;
		q.push(box[i].b - box[i].c);
		sum -= q.top();
		q.pop();
	}
	while(!q.empty()) q.pop(); sum = 0;
	for(int i = n; i > n - x; i--){
		sum += box[i].a - box[i].c;
		q.push(box[i].a - box[i].c);
	}
	for(int i = n - x; i >= y; i--){
		ans = max(ans, tot + lef[i + 1] + sum);
		sum += box[i].a - box[i].c;
		q.push(box[i].a - box[i].c);
		sum -= q.top();
		q.pop();
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3832
//2018年  3月 21日 水曜日 22:12:21 JST-22:21:35
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll H;
ll A[MAX_N], B[MAX_N];
ll S[MAX_N];

void solve() {
	cin >> N >> H;
	rep(i, 0, N) {
		cin >> A[i] >> B[i];
	}
	sort(B, B + N);
	rep(i, 0, N) S[i + 1] = S[i] + B[i];
	ll res = H;
	rep(i, 0, N) {
		int a = A[i];
		int at = upper_bound(B, B + N, a) - B;
		ll sum = S[N] - S[at];
		MIN(res, N - at + max((H - sum + a - 1) / a, 0LL));
	}
	rep(i, 0, N) {
		if(S[N] - S[i] >= H) {
			MIN(res, ll(N - i));
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,s,t) for(auto (i) = (s); (i) <= (t); ++(i))
#define repD(i,t,s) for(auto (i) = (t); (i) >= (s); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,a; cin>>n;
	ll s[100001];
	s[0] = 0;
	rep(i,n){
		cin>>a;
		s[i + 1] = s[i] + a;
	}
	ll ans1 = 0, ans2 = 0,cur1 = 0,cur2 = 0,r1 = 1,r2 = -1;
	rep1(i,n){
		ll t = s[i] + cur1;
		if(r1 * t <= 0){
			ans1 += abs(r1 - t);
			cur1 += r1 - t;
		}
		r1 = -r1;
	}
	rep1(i,n){
		ll t = s[i] + cur2;
		if(r2 * t <= 0){
			ans2 += abs(r2 - t);
			cur2 += r2 - t;
		}
		r2 = -r2;
	}
	cout<<min(ans1,ans2)<<endl;
	
	return 0;
}





Measured memory_bytes: 1024
use std::io::BufRead;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut t = Tokenizer::new(stdin.lock().lines().map(|x| x.unwrap()));

    let n: i32 = t.take();
    let s: String = t.take();
    let ans = problem( n, &s );
    println!("{}",ans);
}

fn problem( n: i32, s: &str ) -> i32 {
    let mut c:u8 = 0;
    let mut n:i32 = 0;
    for b in s.as_bytes().iter() {
        if c != *b {
            n += 1;
            c = *b;
        }
    }
    n
}

#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test1() {
        let result = problem( 10, &"aabbbbaaca" );
        assert_eq!(result,5);
    }
    #[test]
    fn test2() {
        let result = problem( 5, &"aaaaa" );
        assert_eq!(result,1);
    }
    #[test]
    fn test3() {
        let result = problem( 20, &"xxzaffeeeeddfkkkkllq" );
        assert_eq!(result,10);
    }
}


struct Tokenizer<S: Iterator<Item = String>> {
    input: S,
    items: Vec<String>,
}

impl<S: Iterator<Item = String>> Tokenizer<S> {
    pub fn new(input: S) -> Self {
        Tokenizer {
            input: input,
            items: Vec::new(),
        }
    }

    pub fn take<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(r) = self.items.pop() {
                return r.parse().ok().expect("parse failed");
            }
            let mut items = self
                .input
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect::<Vec<String>>();
            items.reverse();
            self.items = items;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
pair<int,int> P;
priority_queue<int,vector<int>,less<int>> pq;
int n,arr[101010],check[101010],ck,len; char st[101010];
bool cmp(int p,int q)
{
    return p>q?1:0;
}
main()
{
    scanf("%s",st);
    len=strlen(st);
    for(int i=0;i<len;i++) arr[i]=1;
    for(int i=0;i<len;i++)
    {
        if(st[i]=='R')
        {
            if(st[i+1]=='R') arr[i+2]+=arr[i], arr[i]=0;
        }
    } for(int i=len-1;i>=0;i--)
    {
        if(st[i]=='L')
        {
            if(st[i-1]=='L') arr[i-2]+=arr[i], arr[i]=0;
        }
    }
    for(int i=0;i<len;i++)
    printf("%d ",arr[i]);
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;


template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}


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

    const int INF = 100000000;
    int N, M;
    int a[1000], b[1000], c[1000], dist[100][100];

    cin >> N >> M;

    REP(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
    }

    // init
    REP(i, N) REP(j, N) {
        if (i == j) dist[i][j] = 0;
        else {
            dist[i][j] = INF;
        }
    }

    //  warshall_floyd
    REP(i, M) {
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    REP(k, N) {
        REP(i, N) {
            REP(j, N) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    // count ignored paths
    int res = 0;
    REP(i, M) {
       if(dist[a[i]][b[i]] != c[i]) ++res;
    }

    cout << res << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define pb push_back
#define ff first
#define ss second
#define all(s) (s).begin(), (s).end()

int main()
{
    int n, m;
    cin >> n >> m;
    int temp = 0, l;
    for (int i = 0; i < m; i++)
        cin >> l, temp += l;
    cout << ((temp <= n)?(n - temp):(-1)) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 1000000007
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;cin>>n;
	ll sub[n+1];
	ll arr[n+1];memset(arr,0,sizeof arr);
	ll ans = 0 ;
	for(int i = 0 ; i < n ; i ++ ){
		cin>>sub[i];
		arr[sub[i]]++;
	}
	for(int i = 1 ; i <= n ; i ++ )ans+=((arr[i]*(arr[i]-1))>>1);
	for(int i = 0 ; i < n ; i ++ ){
		ll val = arr[sub[i]];
		ll an = ans-((val*(val-1))>>1)+(((val-1)*(val-2))>>1);
		cout<<an<<en;
	}
	return 0 ; 
}



Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a[3] = {};
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] * a[1] / 2;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  for (int i = 0; i < N; i++) {
	  int h;
	  cin >> h;
	  if (h >= K) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <queue>
#include <cmath>
#define ll long long int

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

int n, m, s, t;
vector<pair<int, P> > vec[100001];
bool used1[100001];
bool used2[100001];
ll yen[100001];
ll su[100001];
ll res[100001];

bool comp(pair<ll, int> aa, pair<ll, int> bb){
		return aa < bb;
}

int main(int argc, char const* argv[])
{
	cin >> n >> m >> s >> t;
	s--;
	t--;
	for(int i = 0; i < m; i++){
			int u, v, aa, bb;
			cin >> u >> v >> aa >> bb;
			u--;
			v--;
			vec[u].push_back(make_pair(v, make_pair(aa, bb)));
			vec[v].push_back(make_pair(u, make_pair(aa, bb)));
	}
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > q;
	q.push(make_pair(0, s));
	while(!q.empty()){
			pair<ll, int> f = q.top(); q.pop();
			ll dis = f.first;
			int at = f.second;
			if(used1[at])continue;
			used1[at] = true;
			yen[at] = dis;
			for(int i = 0; i < vec[at].size(); i++){
					int to = vec[at][i].first;
					int cost = vec[at][i].second.first;
					if(!used1[to] && to != s){
							q.push(make_pair((ll)dis+(ll)cost, to));
					}
			}
	}
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > qq;
	qq.push(make_pair(0, t));
	while(!qq.empty()){
			pair<ll, int> f = qq.top(); qq.pop();
			ll dis = f.first;
			int at = f.second;
			if(used2[at])continue;
			used2[at] = true;
			su[at] = dis;
			for(int i = 0; i < vec[at].size(); i++){
					int to = vec[at][i].first;
					int cost = vec[at][i].second.second;
					if(!used2[to] && to != t){
							qq.push(make_pair((ll)dis+(ll)cost, to));
					}
			}
	}
	ll maxi = 0;
	for(int i = n - 1; i > -1; i--){
			if(yen[i] <= 1e15)maxi = max(maxi, (ll)(1e15 - (ll)yen[i] - (ll)su[i]));
			res[i] = maxi;
	}
	for(int i = 0; i < n; i++)cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 12148
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
#define f first
#define s second
using namespace std;
int n;
int arr[100005];
ll memo[100005];
ll solve(int idx){
    if (idx==n-1)
        return 0;
    ll &res = memo[idx];
    if(res != -1)
        return res;
    if(idx==n-2)
        return res = abs(arr[n-1]-arr[n-2]);
    return res = min(abs(arr[idx+1]-arr[idx])+solve(idx+1), abs(arr[idx+2]-arr[idx])+solve(idx+2));
}
int main(){
    IO;
    cin >> n;
    memset(memo, -1, sizeof memo);
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
    cout << solve(0);

    return 0;
}


Measured memory_bytes: 2944
use proconio::input;

fn main() {
    input! { x: i64 }
    let mut ans = (0, 0);
    'outer: for a in -1000_i64..1000 {
        for b in -1000_i64..1000 {
            if a.pow(5) - b.pow(5) == x {
                ans = (a, b);
                break 'outer;
            }
        }
    }
    println!("{} {}", ans.0, ans.1);
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

bool check(int x, vector<int>& A, vector<int>& revA, int K) {
    int sum = 0;
    REP (i, A.size()) {
        if (A[i] > 0) {
            if (A[0] * A[i] >= x) continue;
            int ok = 0, ng = A.size();
            while (ng - ok > 1) {
                int m = (ok + ng) / 2;
                if (A[m] * A[i] < x) ok = m;
                else ng = m;
            }
            sum += ng - (i < ng);
        } else {
            if (revA[0] * A[i] >= x) continue;
            int ok = 0, ng = revA.size();
            while (ng - ok > 1) {
                int m = (ok + ng) / 2;
                if (revA[m] * A[i] < x) ok = m;
                else ng = m;
            }
            sum += ng - (A.size() - 1 - i < ng);
        }
    }
    sum /= 2;
    return sum < K;
}

void _main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP (i, N) cin >> A[i];
    sort(A.begin(), A.end());
    vector<int> revA = A;
    reverse(revA.begin(), revA.end());
    const int INF = 1LL << 60;
    int lo = -INF, hi = INF;
    while (hi - lo > 1) {
        int m = (hi + lo) / 2;
        if (check(m, A, revA, K)) lo = m;
        else hi = m;
    }
    cout << lo << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
	int i,j,count,point;
	int n,temp,length;
	char base[3],event[9];

	scanf("%d",&n);
	fgets(event,sizeof(event),stdin);
	count=point=0;
	for(;;){
		fgets(event,sizeof(event),stdin);
		length=strlen(event);
		event[length-1]='\0';
		if(strcmp(event,"HIT")==0){
			if(base[2]==1){
				point+=1;
				base[2]=0;
			}
			if(base[1]==1){
				base[2]=1;
				base[1]=0;
			}
			if(base[0]==1){
				base[1]=1;
			}
			base[0]=1;
		}else if(strcmp(event,"HOMERUN")==0){
			temp=1;
			for(i=0;i<3;i++){
				if(base[i]==1){
					temp++;
				}
				base[i]=0;
			}
			point+=temp;
		}else if(strcmp(event,"OUT")==0){
			count++;
		}
		if(count==3){
			printf("%d\n",point);
			n--;
			count=point=0;
			for(i=0;i<3;i++) base[i]=0;
			if(n==0)break;
		}
	}


	return 0;
}

Measured memory_bytes: 600
n=int(input())
a=[0]*n
a=list(map(int,input().split()))
ans=[0]*n
check=0
for i in range(n):
    check=check^a[i]
for i in range(n):
    ans[i]=check^a[i]
    
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Measured memory_bytes: 114372
N, M = [int(i) for i in input().split()]
pSlist = []
for i in range(M):
    buff = input().split()
    p = int(buff[0])-1
    S = str(buff[1])
    pSlist.append([p,S])

AClist = [0 for i in range(N)]
WAlist = [0 for i in range(N)]
AClist_dummy = [0 for i in range(N)]

for p,S in pSlist:
    if AClist[p]==0 and S=="AC":
        AClist[p]=1
    elif AClist[p]==0 and S=="WA":
        WAlist[p]+=1

sumWA = 0
for p in range(N):
    if AClist[p]==1:
        sumWA+=WAlist[p]

print(sum(AClist),sumWA)

Measured memory_bytes: 24412
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String N = sc.next();
    char n[] = new char[N.length()];
    for (int i = 0; i < N.length(); i++) {
      n[i] = N.charAt(i);
    }
    if (n[1] == n[2] && (n[0] == n[1] || n[2] == n[3])) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

int main() {
  int n;
  double x1,y1,x2,y2,x3,y3,x4,y4,det;
  double vect1[2],vect2[2];

  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    vect1[0] = x2-x1;
    vect1[1] = y2-y1;
    vect2[0] = x4-x3;
    vect2[1] = y4-y3;
    det = vect1[0] * vect2[1] - vect1[1] * vect2[0];
    if(det == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var results = from _ in Enumerable.Range(0, 10)
                      let input = Console.ReadLine()
                      let value = int.Parse(input)
                      orderby value descending 
                      select value;
        foreach (var value in results.Take(3))
        {
            Console.WriteLine(value);
        }
    }
}

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

int N;
bool kind[16];
int n[16] = {0};
vector<pair<int, bool>> test[16];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        for (int j = 0; j < n; j++) {
            int a, b;
            cin >> a >> b;
            a--;
            test[i].push_back(make_pair(a, (bool)b));
            // cout << "(" << a << " " << b << ")" << endl;
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        bool flag = true;
        for (int j = 0; j < N; j++) {
            if (i & (1 << j)) {
                for (pair<int, bool> p : test[j]) {
                    if ((bool)(i & (1 << p.first)) != p.second) {
                        flag = false;
                        break;
                    }
                }
            }
        }
        if (flag) {
            int temp = 0;
            for (int j = 0; j < N; j++) {
                if (i & (1 << j)) {
                    temp++;
                }
            }
            ans = max(ans, temp);
        }
    }
    cout << ans << endl;
}

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


int main()
{
  ll n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  vector<int> counter(100001);
  rep(i, n)
    counter[a[i]]++;
  vector<int> cs(2 * 100000 + 1);
  for (int i=100000; i>=0; i--)
    cs[i] = cs[i+1] + counter[i];
  int l = 0, r = 2 * 100000 + 1;
  while (l + 1 < r)
  {
    int mid = (l + r) / 2;
    ll count = 0;
    rep(i, n)
      count += mid >= a[i] ? cs[mid-a[i]] : cs[0];
    if (count >= m)
      l = mid;
    else
      r = mid;
  }
  sort(a.begin(), a.end());
  vector<ll> cs2(n + 1);
  rep(i, n)
    cs2[i+1] = cs2[i] + a[i];
  ll ans = 0;
  rep(i, n)
  {
    int d = distance(a.begin(), lower_bound(a.begin(), a.end(), l - a[i]));
    ans += a[i] * (n - d) + cs2[n] - cs2[d];
    m -= (n - d);
  }
  ans += m * l;
  cout << ans << endl;
  return 0;
}

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

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

using namespace std;

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i, n) cin >> m[i];
  int result = 0;
  int minValue = INT_MAX;
  rep(i, n) {
    int val = m[i];
    x -= val;
    minValue = min(val, minValue);
    result++;
  }
  while ((x - minValue) >= 0) {
    x -= minValue;
    result++;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	ll n, m;
	pair<ll,ll> P[100000+2];
	
	ll ans = 0;
	ll need;
/* BIEN CUC BO END*/


void solve(){	
	cin >> n >> m;
	for (int i=1; i<=n; ++i){
		cin >> P[i].fs >> P[i].sc;
	}
	sort(P+1,P+1+n);
	for (int i=1; i<=n; ++i){
		if (m == 0) break;
		need = min(m,P[i].sc);
		m -= need;
		ans += P[i].fs*need;
	}
	
	cout << ans;
}

int main(){ FIO;
	solve();
return 0;}	

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
struct fix_point: private T {
  explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return T::operator()(*this, std::forward<Args>(args)...);
  }
};
 
template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
  return fix_point<T>(std::forward<T>(func));
}

constexpr int max_d = 10;

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> graph(N);
  for (int i: range(0, M)) {
    int a, b;
    std::cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int Q;
  std::cin >> Q;
  std::vector<int> V(Q), D(Q), C(Q);
  for (int i: range(0, Q)) {
    std::cin >> V[i] >> D[i] >> C[i];
    --V[i];
  }
  std::vector<std::array<int, max_d + 1>> query(N);
  for (auto &arr: query) {
    arr.fill(0);
  }
  auto dfs = make_fix_point([&](auto dfs, int u, int d, int c) -> void {
    if (query[u][d] > 0) {
      return;
    }
    query[u][d] = c;
    if (d > 0) {
      dfs(u, d - 1, c);
      for (int v: graph[u]) {
        dfs(v, d - 1, c);
      }
    }
  });
  for (int i: revrange(0, Q)) {
    dfs(V[i], D[i], C[i]);
  }
  for (int i: range(0, N)) {
    std::cout << query[i][0] << '\n';
  }
  return 0;
}


Measured memory_bytes: 12024
#include <stdio.h>

int main() {
    long long n,sum=0;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0 )
        sum=sum+i;
    }
    printf("%lld\n",sum);
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

const int lim = 1000000007;

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

    ll ans = 0;
    ll sum = 0;
    int right = 0;
    for(int left = 0; left < N; left++){
        while(right < N && ((sum ^ a[right]) == (sum + a[right]))){
            sum += a[right];
            right++;
        }

        ans += (right - left);

        if(right == left) right++;
        else sum -= a[left];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int h,w;
int c[30][30];
bool tate[30][30],yoko[30][30];

int main()
{
	while(scanf("%d%d",&w,&h),w)
	{
		rep(i,2*h-1)
		{
			if(i%2)rep(j,w)scanf("%d",yoko[i/2]+j);
			else rep(j,w-1)scanf("%d",tate[i/2]+j);
		}
		rep(i,h)rep(j,w)c[i][j]=inf; c[0][0]=0;
		queue<pi> Q; Q.push(mp(0,0));
		while(!Q.empty())
		{
			int y=Q.front().first,x=Q.front().second; Q.pop();
			if(y==h-1&&x==w-1)
			{
				printf("%d\n",c[y][x]+1); goto END;
			}
			rep(d,4)
			{
				int ny=y+dy[d],nx=x+dx[d];
				if(ny<0||ny>=h||nx<0||nx>=w)continue;
				if(d==0&&yoko[y-1][x]||d==1&&tate[y][x-1]||
					d==2&&yoko[y][x]||d==3&&tate[y][x])continue;
				if(c[ny][nx]<=c[y][x]+1)continue;
				c[ny][nx]=c[y][x]+1; Q.push(mp(ny,nx));
			}
		}
		puts("0"); END:;
	}
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3


def solve(N, A):
    ans = 1.0 / sum([1.0 / n for n in A])
    return ans


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    ans = solve(N, A)

    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int a[3];
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    int ans=0;
    for(int i=0;i+1<3;i++){
        ans+=a[i+1]-a[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val n = readInt()
    val a = readIntList().sorted()
    
    val checked = mutableSetOf<Int>()
    var ans = 0

    a.forEachIndexed { index, i ->
        if (i !in checked) {
            if (index == a.size - 1 || a[index + 1] != i) ans += 1
            checked.add(i)
            for (j in i..(1e6).toInt() step i) checked.add(j)
        }
    }

    println(ans)
}


Measured memory_bytes: 142692
#include <stdio.h>

#define W_MAX 1000001
#define MAX 1001

int array[MAX];
int sorted[MAX];

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int calc_cost(int n, int min_pos, int flag){
  int loop_pos = min_pos;
  int i, sum = 0;
  int min = array[min_pos];

  do{
    for(i = 0; i < n; i++){
      if(array[i] == sorted[loop_pos]){
	sum += array[i] + min;

	if(flag){ swap(&array[i], &array[loop_pos]); }

	loop_pos = i;
	
	break;
      }
    }
    
    
    if(0){
      for(i = 0; i < n; i++){
	printf("%s%d", i == 0 ? "" : " ", array[i]);
      }
      printf(" : %d\n", sum);
    }else{
      //printf("%d\n", sum);
    }
    
  }while(min != sorted[loop_pos]);

  return sum;
}

int greedy(int n){
  int i, j;
  int absolute_min = sorted[0], absolute_min_pos = -1;
  int min = W_MAX, min_pos = -1;
  int loop_pos = -1;
  int direct_sum = 0;
  int indirect_sum = 0;

  for(i = 0; i < n; i++){
    if(array[i] == absolute_min){
      absolute_min_pos = i;
      break;
    }
  }

  for(i = 0; i < n; i++){
    if(min > array[i] && sorted[i] != array[i]){
      min = array[i];
      min_pos = i;
    }
  }

  if(min_pos == -1){
    return 0;
  }

  //printf("absolute_min = %d(%d)\n", absolute_min, absolute_min_pos);

  direct_sum += calc_cost(n, min_pos, 0);
  
  swap(&array[min_pos], &array[absolute_min_pos]);
  indirect_sum += array[min_pos] + array[absolute_min_pos];
  indirect_sum += calc_cost(n, min_pos, 0);
  swap(&array[min_pos], &array[absolute_min_pos]);

  //printf("min = %d, direct_sum = %d, indirect_sum = %d\n", min, direct_sum, indirect_sum);

  if(direct_sum <= indirect_sum){
    calc_cost(n, min_pos, 1);
    
    return direct_sum + greedy(n);
  }else{
    swap(&array[min_pos], &array[absolute_min_pos]);
    //printf("%d\n", 
    calc_cost(n, min_pos, 1);

    return indirect_sum + greedy(n);
  }

  return 0;
}

int main(int argc, char* argv[]){
  int i, j, n;
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &array[i]);
    sorted[i] = array[i];
  }
  
  for(i = 0; i < n; i++){
    int min = sorted[i];
    int min_pos = i;
    
    for(j = i + 1; j < n; j++){
      if(min > sorted[j]){
	min = sorted[j];
	min_pos = j;
      }
    }

    if(min_pos != i){
      swap(&sorted[i], &sorted[min_pos]);
    }
  }


  printf("%d\n", greedy(n));

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) v.begin(), v.end()
#define ll long long
ll INF = 1e9;
ll mod = 1e9+7;

ll dp[10001];
int main() {
  int n; string s; cin >> n >> s;
  int ans = 0;
  for(int i = 0; i <= n - 3; i++) {
  if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }
	cout << ans << endl;
}

Measured memory_bytes: 256
def sequence(x):
	A=[x]
	for i in range(1,10):
		if i%2:
			A.append(A[i-1]*2)
		else:
			A.append(A[i-1]/3)
	return sum(A)

while True:
	try:
		x=float(input())
		print(sequence(x))
	except EOFError:
		break

Measured memory_bytes: 7548
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
# 累積和
cur = 0
b = []
for i in range(1, len(a)):
    b.append(abs(a[i] - cur))
    cur = a[i]
s = sum(b)

for i in range(1, n + 1):
    print(s + abs(a[i + 1] - a[i - 1]) - (abs(b[i - 1]) + abs(b[i])))


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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 1e7 + 10;
const int M = (int) 350;
const int K = (int) 350;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  vec a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  if (a[0] % 2 == a[1] % 2) {
    if (a[2] % 2 == a[0] % 2) 
      cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
    else 
      cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2 + 1; 
  } else {
    cout << a[2] - a[1] + 2 + (a[1] - a[0]) / 2;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A+B+C<=21)
        {
            System.out.println("win");
        }
        else
        {
            System.out.println("bust");
        }
    }
}

Measured memory_bytes: 23764
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, A: "List[int]"):
    for i in range(N-K):
        if A[i]<A[i+K]:
            print(YES)
        else:
            print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 93572
#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 << "Balanced" << endl;
  }else if(a+b < c+d){
    cout << "Right" << endl;
  }else{
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
# O(EV)
def bellman_ford(s):
    d = [float('inf')]*n # 各頂点への最短距離
    d[s] = 0 # 自身への距離は0
    for i in range(n):
        update = False
        for x, y, z in g:
            if d[y] > d[x] + z:
                d[y] = d[x] + z
                update = True
        if not update:
            break
        # 負閉路が存在
        if i == n - 1:
            return -1
    return d

n, w, s = [int(x) for x in input().split()] # n:頂点数, w:辺の数
g = []
for _ in range(w):
    x, y, z = [int(x) for x in input().split()] # 始点,終点,コスト
    g.append([x, y, z])
d = bellman_ford(s)
if d == -1:
    print("NEGATIVE CYCLE")
else:
    for i in d:
        if i == float("inf"):
            print("INF")
        else:
            print(i)


Measured memory_bytes: 6040
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9;
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <ii> v[100000];
map <lo,lo> mp1;
map <string,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
lo dp[100000];
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    cin >> n;
    for(lo i = 0 ; i < n ; i++){
        cin >> a1[i];
    }
    dp[1] = abs(a1[0] - a1[1]);
    for(lo i = 2 ; i < n ; i++){
        dp[i] = min(dp[i - 1] + abs(a1[i] - a1[i - 1]), dp[i - 2] + abs(a1[i] - a1[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

int gcd(int a,int b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
int32_t main(){
	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n);
    REP(i,0,n)cin>>a[i];

    int ans=a[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<"\n";


	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = s[k-1] + 0x20;
    cout << s << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
int main(){
    int n;
    cin>>n;
    map<string,ll> m;

    rep(i,n){
        string s;
        cin>>s;
        sort(all(s));
        m[s]++;
    }

    ll ans=0;
    for(auto e : m){
        ll tmp=e.second*(e.second-1)/2;
        ans+=tmp;
    }
    
    cout<<ans<<endl;
}

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

int main()
{
    string s;
    cin >> s;
    string ans = "NO";
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<s.size()-i; j++){
            string t = s;
            t.erase(i,j);
            // cout << t << endl;
            if(t == "keyence") ans = "YES";
        }
    }

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

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let cs: Vec<char> = (b'a'..b'z'+1).map(|c| c as char).collect();
    let ss: Vec<char> = cs.into_iter().filter(|c| !s.contains(c)).collect();
    if ss.is_empty() {
        println!("None");
    } else {
        println!("{}", ss[0]);
    }
}


Measured memory_bytes: 4352
main = do
	cs <- getLine
	let a:b:c:_ = toIntList cs
	putStrLn $ showAnswer a b c

toIntList :: String -> [Integer]
toIntList = map read . words

showAnswer :: Integer -> Integer -> Integer -> String
showAnswer a b c
	| a < b && b < c = "Yes"
	| otherwise = "No"


Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    map<string, ll> mp;
    rep(i, n) {
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }

    ll ans = 0;
    for(auto p : mp) {
        ans += p.second*(p.second-1)/2;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 11136
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C,D;
  int x,y;
  cin>>A>>B>>C>>D;
  if(C%B==0)
    x=C/B;
  else
    x=C/B+1;
  if(A%D==0)
    y=A/D;
  else
    y=A/D+1;
  if(x>y)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;   

}


Measured memory_bytes: 3652
n, blue, red = map( int, input().split() )

box = n // (blue + red)       #variable box indicates how much sets of a line can get into n
mod = n % (blue + red)

#最後に青の残り(r_blue)がどれだけあるか
if mod <= blue:    #余りが全部青
    r_blue = mod
else:              #余りが一部赤
    r_blue = blue

print(box * blue + r_blue)

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

int n;
int x[110][110];
int dp[110][110];

int main () {

	cin >> n;
	for (int i = 1; i <= 2; i ++) {
		for (int j = 1; j <= n; j ++) {
			cin >> x[i][j];
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + x[i][j];
		}
	}
	cout << dp[2][n];

	return 0;
}


Measured memory_bytes: 256