akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn];
int Pow(int b) {
    int ans = 1, base = 2;
    while (b != 0) {
        if (b & 1 != 0)
            ans *= base;
        base *= base;
        b >>= 1;
    }
    return ans;
}
int32_t main()
{
    IOS
    cin>>n>>m;
    double ans;
    cout<<setprecision(12)<<fixed;
    fun(i)
    {
        int now=i,time=0;
        while(now<m)
        {
            now*=2;
            time++;
        }
        ans+=(double)1/(double)(Pow(time)*n);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int n,m,cou=0,res=0;
string s,t;                
int main() {
	cout << fixed << setprecision(10);
	cin>>s>>t;
	if(s[0]==t[0]){cou++;}
	if(s[1]==t[1]){cou++;}
	if(s[2]==t[2]){cou++;}
	cout<<cou<<endl;
} 


Measured memory_bytes: 256
module WeightedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  val prim :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 最小全域木に含まれる辺のリスト *)
    (Vertex.t * Vertex.t * Weight.t) list
end =
struct
  module VSet = Set.Make (Vertex)
  module WMap = Map.Make (Weight)

  (*
   * プリム法のメインループ
   * es : 隣接リスト
   * vs : 訪れた頂点の集合
   * q : 訪れた頂点から伸びる辺が重み順に入ったヒープ
   * acc : 最小全域木に使うのが確定した辺を入れるやつ
   *)
  let rec prim_aux es acc vs q =
    match WMap.min_binding q with
    | exception Not_found -> acc
    | (w, []) -> prim_aux es acc vs (WMap.remove w q)
    | (w, (u, v) :: rest) ->
        if VSet.mem v vs then
          (* vは既に訪れていた *)
          prim_aux es acc vs (WMap.add w rest q)
        else
          (* vはまだ訪れていなかった *)
          prim_aux es ((u, v, w) :: acc) (VSet.add v vs) @@
            (* vから伸びる辺をキューに追加 *)
            List.fold_left (fun q (u, w) ->
              (* 現時点で既に訪れている頂点への辺は追加しない *)
              if VSet.mem u vs
              then q
              else WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q) (WMap.add w rest q) (es v)

  let prim es s =
    prim_aux es [] (VSet.singleton s) @@
      (* 始点から伸びる辺をキューに入れておく *)
      List.fold_left (fun q (v, w) ->
        WMap.add w ((s, v) :: try WMap.find w q with Not_found -> []) q) WMap.empty (es s)
end


module Int = struct
  type t = int
  let compare = compare
end

module G = WeightedGraph (Int) (Int)

let () = Scanf.scanf "%d\n" (fun n ->
  let xys = Array.to_list @@ Array.init n (fun i -> Scanf.scanf "%d %d\n" (fun x y -> x, y, i)) in
  let es = Array.make n [] in
  begin match List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  begin match List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  G.prim (Array.get es) 0
  |> List.map (fun (_, _, w) -> w)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n")


Measured memory_bytes: 66176
#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;
const ll INF = (ll)1000000007 * 1000000007;
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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n, m;
ld x[14], y[14];
ld d[14][14];
ld rd[1 << 14];
bool can(int s,ld r) {
	vector<int> v;
	rep(i, n) {
		if (s&(1 << i))v.push_back(i);
	}
	if (v.size() <= 1)return true;
	int len = v.size();
	rep(i, len) {
		Rep(j, i + 1, len) {
			int id = v[i], jd = v[j];
			if (2*r < d[id][jd])return false;
			ld X = (x[jd] - x[id]) / 2.0;
			ld Y = (y[jd] - y[id]) / 2.0;
			ld dist = sqrt(pow(r, 2) - pow(d[id][jd] / 2.0, 2));
			ld sr = d[id][jd] / 2.0;
			ld x3 = Y * dist / sr; ld y3 = -X * dist / sr;
			ld midx = (x[id] + x[jd]) / 2.0, midy = (y[id] + y[jd]) / 2.0;
			ld cx = x3 + midx, cy = y3 + midy;
			bool valid = true;
			rep(k, len) {
				int kd = v[k];
				ld dis = sqrt(pow(cx - x[kd], 2) + pow(cy - y[kd], 2));
				if (dis > r+eps) {
					valid = false; break;
				}
			}
			if (valid)return true;
			valid = true;
			cx = -x3 + midx, cy = -y3 + midy;
			rep(k, len) {
				int kd = v[k];
				ld dis = sqrt(pow(cx - x[kd], 2) + pow(cy - y[kd], 2));
				if (dis > r+eps) {
					valid = false; break;
				}
			}
			if (valid)return true;
		}
	}
	return false;
}
ld dp[1 << 14], cop[1 << 14];
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	rep(i, n) {
		rep(j, n) {
			d[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
		}
	}
	rep(i, (1 << n)) {
		ld le = 0, ri = 200000;
		while (ri - le > eps) {
			ld r = (ri + le) / 2;
			if (can(i, r))ri = r;
			else le = r;
		}
		rd[i] = ri;
	}
	fill(dp, dp + (1 << n), mod);
	dp[0] = 0;
	rep(aa, m) {
		rep(j, (1 << n)) {
			cop[j] = dp[j];
		}
		rep(j, (1 << n)) {
			vector<int> v;
			rep(i, n) {
				if (j&(1 << i))continue;
				v.push_back(i);
			}
			int len = v.size();
			rep(i, (1 << len)) {
				int s = 0;
				rep(k, len) {
					if (i&(1 << k))s += (1 << v[k]);
				}
				cop[j + s] = min(cop[j + s], max(dp[j], rd[s]));
			}
		}
		rep(j, (1 << n)) {
			dp[j] = cop[j];
		}
	}
	cout << fixed << setprecision(5);
	cout << dp[(1 << n) - 1] << endl;
	//stop
	return 0;
}


Measured memory_bytes: 3996
n,m=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
t=0
#print(A)
for i in range(n):
    t+=A[i]
l=0
#print(t)
g=t*(1/(4*m))
#print(g)
c=0
for i in range(m):
    l=A.pop()
    #print(l)
    if l<g:
        c+=1
    else:
        c+=0
    #print(c)
if c==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
function main(input) {
  const S = input.split('');
  
  if (S[0] === 'A') {
    console.log('T');
  } else if (S[0] === 'T') {
    console.log('A');
  } else if (S[0] === 'C') {
    console.log('G');
  } else if (S[0] === 'G') {
    console.log('C');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29484
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
const int N = 1e5 + 5;
int p[N], q[N];
vector <pair <int, int> > edge;
int h, w;
signed main()
{
	int ans = 0;
	cin >> h >> w;
	for(int i = 1; i <= h; i++)
	{
		cin >> p[i];
		edge.push_back({p[i], 0});
	}
	for(int i = 1; i <= w; i++)
	{
		cin >> q[i];
		edge.push_back({q[i], 1});
	}
	h++, w++;
	sort(edge.begin(), edge.end());
	for(auto e : edge)
	{
		// cout << e.fi << ' '; 
		if(e.se == 0)
		{
			ans += (w * e.fi);
			h--;
		}
		else
		{
			ans += (h * e.fi);
			w--;
		}
		// if(h == 0 || w == 0)
			// return cout << ans, 0;
	}
	cout << ans;
}

Measured memory_bytes: 7152
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime> 
#include <map> 
#include <set> 
using namespace std; 
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll n,front,last;
ll gcd(ll x,ll y)
{
    return y==0?x:gcd(y,x%y);
}
ll lcm(ll x,ll y)
{
    return x/gcd(x,y)*y;
}
int main()
{
    while(scanf("%lld",&n)!=EOF)
    {
        scanf("%lld",&front);
        for(int i=1;i<n;i++)
        {
            scanf("%lld",&last);
            front=lcm(front,last);
        }
        printf("%lld\n",front);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------


int main(){
	ll a ;
	cin >> a;
	PRT(a*a);
	return 0;
}









Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B ;
    cin >> A >> B ;
    cout << max(A+B, max(A-B, A*B)) << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> input(H,vector<char>(W));
  vector<bool> flagH(H,0), flagW(W,0);
  for (int i = 0; i < H; i++) {
  	for(int j=0;j<W;j++){
      cin >> input.at(i).at(j);
      if(input.at(i).at(j)=='#'&&flagH.at(i)==0){
      	flagH.at(i)=1;
	  }
	  if(input.at(i).at(j)=='#'&&flagW.at(j)==0){
	  	flagW.at(j)=1;
	  }
    }
  }

  for (int i=0;i<H;i++){
  	if(flagH.at(i)){
  	  for (int j=0;j<W;j++){
  	    if(flagW.at(j)){
            cout << input.at(i).at(j);
	    }
	  }
	  cout << endl;
    }
  }
  
  return 0;
}


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

int main()
{
	int n,i,min,max;
	long sum=0;
	cin>>n;
	int a[n];
	
	for(i=0;i<n;i++)
	cin>>a[i];
	min = a[0];
	max = a[0];
	
	for(i=0;i<n;i++){
		if(min>a[i])
			min=a[i];
			}
			
	for(i=0;i<n;i++){
		if(max<a[i])
			max=a[i];
			}
	for(i=0;i<n;i++){
	sum += a[i];
	}
	
	cout<<min<<" "<<max<<" "<<sum<<endl;
	
	return 0;
}

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

int main(){
  int N, flag=0;
  cin >> N;
  
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if( S == "Y"){
      flag = 1;
      break;
    }
  }
  
  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  int a;
  cin>>a;
  a=a+a*a+a*a*a;
  cout<<a<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(char *s)
{
    int i;
    for(i = 1; i < strlen(s); i++) {
        if(s[i - 1] != s[i]) {
            printf("Yes\n");
            return;
        }
    }
    printf("No\n");
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    char S[4];
    scanf("%s", S);
    solver(S);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long n,a,b,x[100010],ans=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
    {
    	cin>>x[i]; 
	}
        
    for(int i=1;i<n;i++)
    {
		ans+=min(a*(x[i+1]-x[i]),b); 
	}
        
    cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 1024
from itertools import combinations
import sys
readline = sys.stdin.readline
write = sys.stdout.write
cs = "XX23456789TJQKA"
ss = "SHDC"
def conv(s):
    return ss.index(s[0]), cs.index(s[1])
c_mp = {}
for i in range(9):
    es = []
    for j in range(5):
        es.append(((i+j)%13)+2)
    xs = tuple(sorted(es))
    c_mp[xs] = es[-1]
c_mp[2, 3, 4, 5, 14] = 5

def calc(p):
    xs = [b for a, b in p]
    xs.sort()
    key = tuple(xs)
    mp = {}
    for x in xs:
        mp[x] = mp.get(x, 0) + 1
    ys = sorted(mp.items(), key = lambda x: (x[1], x[0]), reverse = True)
    m = p[0][0]
    s = (all(a == m for a, b in p))
    if s and xs == [10, 11, 12, 13, 14]:
        # Royal straight flush
        return [9, 0]
    if s and key in c_mp:
        # Straight flush
        return [8, c_mp[key]]
    if ys[0][1] == 4:
        # Four of a kind
        p, q = ys
        return [7, (p[0], q[0])]
    if ys[0][1] == 3 and ys[1][1] == 2:
        # Full house
        p, q = ys
        return [6, (p[0], q[0])]
    if s:
        # Flush
        return [5, xs[::-1]]
    if key in c_mp:
        # Straight
        return [4, c_mp[key]]
    if ys[0][1] == 3:
        # Three of a kind
        p, q0, q1 = ys
        return [3, (p[0], q0[0], q1[0])]
    if ys[0][1] == 2 and ys[1][1] == 2:
        # Two pairs
        p0, p1, q = ys
        return [2, (p0[0], p1[0], q[0])]
    if ys[0][1] == 2:
        # One pair
        p, q0, q1, q2 = ys
        return [1, (p[0], q0[0], q1[0], q2[0])]
    # High card
    return [0, xs[::-1]]

def select(C):
    k = None
    for p in combinations(C, r = 5):
        r = calc(p)
        if k is None or k < r:
            k = r
    return k

def check(A, B, C):
    PA = select(A + C)
    PB = select(B + C)
    return PA > PB

def solve():
    s = readline().strip()
    if s == "#":
        return False
    *A, = map(conv, s.split())
    *B, = map(conv, readline().split())
    *C, = map(conv, readline().split())
    E = [[1]*15 for i in range(4)]
    for p, q in A + B + C:
        E[p][q] = 0
    cnt = su = 0
    for i0 in range(4):
        for j0 in range(2, 15):
            if E[i0][j0] == 0:
                continue
            for i1 in range(4):
                for j1 in range(2, 15):
                    if E[i1][j1] == 0 or (i0, j0) >= (i1, j1):
                        continue
                    if check(A, B, C + [(i0, j0), (i1, j1)]):
                        cnt += 1
                    su += 1
    write("%.16f\n" % (cnt / su))
    return True
while solve():
    ...



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

int main() {
    int h,w;
    while(1) {
        scanf("%d%d",&w,&h);
        if(w==0 && h==0) break;
        for(int i=0; i<w; i++) {
            for(int j=0; j<h; j++) {
                if((i+j)%2==0)printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;

}



Measured memory_bytes: 3172
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<functional>
#define p pair<int,int>
#define P pair<int,p>//from kaisya ID
using namespace std;

vector<p>rinsetu[500000];
P B[400000];
int mincost[500000];
vector<int>ans;
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	//３種類の辺
	//同じ会社　違う会社　電車に乗る
	for (int c = 0; c < b; c++) {
		int d, e, f; scanf("%d%d%d", &d, &e, &f); d--; e--;
		if (d > e)swap(d, e);
		if (e == a - 1) {
			ans.push_back(a + c * 2 + 1);
		}
		rinsetu[d].push_back({ 1,a + c * 2 });
		rinsetu[a + c * 2].push_back({ 0,d });
		rinsetu[e].push_back({ 1,a + c * 2+1 });
		rinsetu[a + c * 2 + 1].push_back({ 0,e });
		rinsetu[a + c * 2].push_back({ 0,a + c * 2 + 1 });
		rinsetu[a + c * 2 + 1].push_back({ 0,a + c * 2 });
		B[c * 2] = { d,{ f,a + c * 2 + 1 } };
		B[c * 2 + 1] = { e,{f,a + c * 2} };
	}
	sort(B, B + b * 2);
	for (int i = 1; i < b * 2; i++) {
		if (B[i].first == B[i - 1].first&&B[i].second.first == B[i - 1].second.first) {
			rinsetu[B[i].second.second].push_back({ 0,B[i - 1].second.second });
			rinsetu[B[i-1].second.second].push_back({ 0,B[i].second.second });
		}
	}
	memset(mincost, 0x3f, sizeof(mincost));
	mincost[0] = 0;
	priority_queue<p, vector<p>, greater<p>>Q;
	Q.push({ 0,0 });
	while (Q.size()) {
		p i = Q.top(); Q.pop();
		for (p t : rinsetu[i.second]) {
			if (mincost[t.second] > mincost[i.second] + t.first) {
				mincost[t.second] = mincost[i.second] + t.first;
				Q.push({ mincost[i.second] + t.first, t.second });
			}
		}
	}
	int MIN = 1 << 29;
	for (int i : ans) {
		MIN = min(MIN, mincost[i]);
	}
	if (MIN == 1 << 29)puts("-1");
	else cout << MIN << endl;
}

Measured memory_bytes: 53872
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;

class Program
{

    static void Main(string[] args)
    {
        label:
        int count = Parse(ReadLine());
        var result = new int[count];
        for (int i = 0; i < result.Length - 1; ++i)
        {
            var sp = ReadLine().Split();
            int c = Parse(sp[0]);
            int s = Parse(sp[1]);
            int f = Parse(sp[2]);
            result[i] = s + c;
            for (int j = 0; j < i; ++j)
            {
                if (result[j] <= s) result[j] = s + c;
                else
                {
                    result[j] = (result[j] + f - 1) / f * f + c;
                }
            }
        }
        foreach (int n in result)
        {
            WriteLine(n);
        }
    }
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, n, m, k);
  vector<ll> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  ll sum = 0;
  ll ai = 0;
  while (ai < a.size()) {
    if (sum + a[ai] <= k) {
      sum += a[ai++];
    } else {
      break;
    }
  }
  ll bi = 0;
  while (bi < b.size()) {
    if (sum + b[bi] <= k) {
      sum += b[bi++];
    } else {
      break;
    }
  }
  ll ans = ai + bi;
  while (ai > 0) {
    sum -= a[--ai];
    dbg(sum);
    while (bi < b.size()) {
      if (sum + b[bi] <= k) {
        sum += b[bi++];
      } else {
        break;
      }
    }
    ans = max(ans, ai + bi);
  }
  out(ans);
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
	#define endl "\n"
	#define ll long long int
	#define vi vector<ll>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<ll,ll>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	
	signed main()
	{

	std::ios::sync_with_stdio(false);
	
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	int n; cin>>n;
	int a = n%10;
	if(a==3)
		cout<<"bon";
	else if(a==0 || a==6 || a==1 || a==8)
		cout<<"pon";
	else
		cout<<"hon";
	return 0;
	}


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

int main(){
  ll n, m;
  cin >> n >> m;
  if(n == 1 || m == 1){
    if(n == 1 && m != 1){cout << max(m-2, 0LL) << endl;}
    else if(m == 1 && n != 1){cout << max(n-2, 0LL) << endl;}
    else{cout << 1 << endl;}
    }
  else{
    ll ans = (n-2) * (m-2);
    cout << ans << endl;
  }
}


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

int main() {
  string s;
  bool flag = false;
  cin >> s;
  
  for(int i = 0; i<2;i++){
	 if(s[i] == s[i+1] && s[i+1] == s[i+2]){
     	flag = true;
     }
  }
  
  if(flag){
	cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
}

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

using namespace std;

const int NODE = 100;
const int TICKET = 10 + 1;
const int INF = 1 << 20;	// 1048576

int E[NODE][NODE];
int cost[TICKET][NODE];
bool used[NODE];

void dijkstra ( int C, int N, int S )
{
	for (int c = 0; c <= C; ++c)
	{
		for (int i = 0; i < N; ++i)
			used[i] = false;
		
		cost[c][S] = 0;
		
		while ( 1 )
		{
			int v = -1;
			for (int i = 0; i < N; ++i)
				if ( !used[i] && ( v == -1 || cost[c][v] > cost[c][i] ))
					v = i;
			if ( v == -1 ) break;
			
			used[v] = true;
			
			if ( c )
				for (int i = 0; i < N; ++i)
				{
					cost[c][i] = min(cost[c][i], min(cost[c][v] + E[v][i] , cost[c-1][v] + E[v][i] / 2));
				}
			else
				for (int i = 0; i < N; ++i)
				{
					cost[c][i] = min(cost[c][i], cost[c][v] + E[v][i]);
				}
		}
	}
}

void init ( void )
{
	for (int i = 0; i < NODE; ++i)
	{
		for (int j = 0; j < NODE; ++j)
			E[i][j] = INF;
		for (int j = 0; j < TICKET; ++j)
			cost[j][i] = INF;
	}	
}

int main ( void )
{
	int c, n, m, s, d;
	
	while ( cin >> c >> n >> m >> s >> d,
		c | n | m | s | d )
	{
		init();
		
		for (int i = 0, a, b, f; i < m; i += 1)
		{
			cin >> a >> b >> f;
			E[a-1][b-1] = E[b-1][a-1] = f;
		}
		
		dijkstra( c, n, s-1 );
		
		cout << cost[c][d-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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


int main(){
    int N;
    cin >> N;
    vector<int>a(N);
    REP(i, N) cin >> a.at(i);
    sort(all(a));
    reverse(all(a));

    int cnt = N - 1;
    
    REP(i, N){

      if(a.at(i) != cnt) {
            print(0);
            return 0;
        }
        if(i % 2 != 0) cnt -= 2;
    }
    int ans = 1;
    REP(i, N / 2){
        ans *= 2;
        ans %= MOD;
    }
    print(ans);
}

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

int main(){
	int h, w;
	cin >> h >> w;
	int d;
	cin >> d;
	string f = "RYGB";
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(d % 2){
				int c = (i%2)*2+(j%2);
				cout << f[c];
				continue;
			}
			int x = i + j;
			int y = i - j;
			x %= 2*d;
			y %= 2*d;
			while(x < 0) x += 2*d;
			while(y < 0) y += 2*d;
			x /= (d);
			y /= (d);
			int c = 2*x+y;
			cout << f[c];
		}
		cout << endl;
	}
}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int n, a[1000];

double f1() {
	int ab = a[n - 1] + a[n - 2], cd = INF;
	for (int i = 1; i < n - 2; ++i)
		cd = min(cd, a[i] - a[i - 1]);
	return (double)ab / cd;
}

double f2() {
	int ab = 0, cd = INF, s;
	for (int i = 1; i < n; ++i) {
		if (cd > a[i] - a[i - 1]) {
			cd = a[i] - a[i - 1];
			s = i;
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		if (i == s || i == s + 1 || i == s - 1)
			continue;
		ab = max(ab, a[i] + a[i - 1]);
	}
	return (double)ab / cd;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);

	cout << fixed << setprecision(6) << max(f1(), f2()) << endl;

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define loop(i,arr) for (auto i: arr)

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b;cin>>a>>b;
    cout<<(a+b)%24<<endl;
    return 0;
}

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

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

using namespace std;

int main(){
  int d;
  cin>>d;
  
  cout<<"Christmas";
  
  rep(i, 25-d){
    cout<<" Eve";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N >> K;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int sum = 0;
	cout << K / v[0] + 1 << endl;
	K -= v[0];
	int box = 0;
	for (int i = 1; i < N; i++) {
		if (v[i] >= v[box]) {
			K -= sum;
			sum = 0;
			cout << max(1LL,K / v[i] + 1) << endl;
			box = i;
			K -= v[i];
		}
		else {
			//cout << "jiji";
			cout << max(1LL,(K-sum+v[box]-v[i]) / v[box] + 1) << endl;
			sum += v[i];
		}
	}
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
  ll n;
  cin >> n;
  ll ans = 1;
  REP(i, n){
    ans = (ans * (i + 1)) % MOD;
  }
  cout << ans << endl;
}


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

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

int N, K;
string S;

int main()
{
    cin >> N >> K;
    cin >> S;

    int z_cnt = 0;
    bool z_init = false;

    vector<int> v;
    char pre = '2';
    int pos = -1;

    REP(i, N)
    {
        if (i == 0 && S[i] == '0')
            z_init = true;

        if (S[i] == '0')
            z_cnt++;

        if (pre != S[i])
        {
            v.push_back(1);
            pre = S[i];
            pos++;
        }
        else
        {
            v[pos]++;
        }
    }

    int rev = min(K, z_cnt);

    ll sum[2 * v.size()];
    M0(sum);

    REP(i, v.size() + 1)
    {
        if (i == 0)
            sum[i] = 0;
        else
            sum[i] = sum[i - 1] + v[i - 1];
    }

    ll m = 0;

    int z_left = z_init ? 0 : 1;
    int z_right = z_left + 2 * (rev - 1);

    for (;;)
    {
        int left = max(z_left - 1, 0);
        int right = min(z_right + 1, (int)v.size() - 1);
        chmax(m, sum[right + 1] - sum[left]);

        z_left += 2;
        z_right += 2;

        if (right == (int)v.size() - 1)
            break;
    }

    cout << m << endl;
}

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

int main(){
	double a;
	double sum;
	while (cin >> a) {
		sum = 0;
		for (int i = 1; i <= 10; i++) {
			sum += a;
			if (i % 2) {
				a = a * 2;
			}else {
				a = a / 3;
			}
		}
		cout << setprecision(20);
		cout << sum << endl;
	} 
	return 0;
}

Measured memory_bytes: 0
N = int(input())
ans = 0
d = {'A':0,'B':0,'BA':0}
for i in range(N):
    s = input()
    ans += s.count('AB')
    if s[0]!='B' and s[-1]!='A':
        continue
    else:
        if s[0]+s[-1]=='BA':
            d['BA']+=1
        else:
            if s[0]=='B':
                d['B']+=1
            else:
                d['A']+=1
        
ans += min(d['A'],d['B'])
if d['A']==0 and d['B']==0:
    ans += max(0,d['BA']-1)
else:
    ans += d['BA']
print(ans)

Measured memory_bytes: 45160
x, y, a, b, c = gets.split.map(&:to_i)

pp = gets.split.map(&:to_i).sort_by{|e| -e}[0..(x-1)]
q = gets.split.map(&:to_i).sort_by{|e| -e}[0..(y-1)]
r = gets.split.map(&:to_i).sort_by{|e| -e}

sum = pp.inject(:+) + q.inject(:+)
i = x - 1
j = y - 1
k = 0

loop do
    break if k >= c || (i < 0 && j < 0)

    s = (i >= 0 ? r[k] - pp[i] : 0)
    t = (j >= 0 ? r[k] - q[j] : 0)

    if s > 0 && t > 0
        if s > t
            sum += s
            i -= 1
            k += 1
        else
            sum += t
            j -= 1
            k += 1
        end
    elsif s > 0
        sum += s
        i -= 1
        k += 1
    elsif t > 0
        sum += t
        j -= 1
        k += 1
    else
        break
    end
end

puts sum

Measured memory_bytes: 26720
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <algorithm>
// #include "./Debug.h"

namespace AtCoder {
	using Input = std::vector<std::string>;
	using Num = std::vector<int>;

	Input input(void) {
		Input result;
		{
			std::string buf = "", row = "";
			std::getline(std::cin, buf);
			for (unsigned int i = 0; i < buf.size(); i++) {
				if (' ' == buf[i]) {
					result.push_back(row);
					row = "";
				} else {
					row += buf[i];
				}
			}
			result.push_back(row);
		}
		return result;
	}

	Num replaceToInteger(Input original = { "" }) {
		Num result;
		for (unsigned int i = 0; i < original.size(); i++) {
			result.push_back(atoi(original[i].c_str()));
		}
		return result;
	}
}

int main(void) {

	AtCoder::Num s = AtCoder::replaceToInteger(AtCoder::input());

	const int a = s[0], b = s[1], c = s[2];

	int ans = c - (a - b);

	ans = 0 > ans ? 0 : ans;

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

	return 0;
}


Measured memory_bytes: 888
import math
a, b, h, m= map(int, input().split())

r = 0
rm = 6*m
rh = 30*h + m/2

if abs(rm-rh) < 180:
  r = abs(rm-rh)
else:
  r = 360 - abs(rm-rh)

if r==180:
  print(format(a+b, '.25f'))
else:
  print(format((math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(r)))),'.25f'))
  

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

using namespace std;

long long f(long long b, long long n) {
    if (b <= 1) return -1;
    if (n < b) return n;
    else return f(b, n / b) + n % b;
}
int main() {
    long long n, s;

    scanf("%lld%lld", &n, &s);
    long long res = 1e13 + 1;

    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    for (long long b = 2; b * b <= n; ++b) {
        if (f(b, n) == s) res = min(res, b);
    }

    for (long long p = 1; p * p < n; ++p) {
        long long r = s - p;
        long long b = (n - r) / p;
        if (b == 1) continue;
        if (f(b, n) == s) res = min(res, b);
    }

    if (res == 1e13 + 1) cout << -1 << endl;
    else cout << res << endl;


    return 0;
}



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

  string s;
  cin>>s;
  
  string key="keyence";

  if(s==key){cout<<"YES"<<endl;return 0;}
  
  int N=s.size();

  rep(i,N){

    for(int leng=1;leng<N-i+1;leng++){

      //cout<<i<<" "<<leng<<endl;
      string t=s;
      t.erase( t.begin()+i, t.begin()+i+leng);
      if(t==key){cout<<"YES"<<endl;return 0;}
      //cout<<t<<endl;
    }
  }
  
  cout<<"NO"<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

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

    ll A[N + 1];
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    ll sum[N + 1], xorsum[N + 1];
    sum[0] = xorsum[0] = 0;
    for (int i = 1; i <= N; ++i) {
        sum[i] = sum[i - 1] + A[i];
        xorsum[i] = (xorsum[i - 1] ^ A[i]);
    }

    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        int ok = i, ng = N + 1;

        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (sum[mid] - sum[i - 1] == (xorsum[mid] ^ xorsum[i - 1])) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        ans += ok - i + 1;
    }

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


Measured memory_bytes: 4992
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto ab = readints;
    int a = ab[0], b = ab[1];

    int ans = a * b - a - b + 1;
    writeln(ans);
}


Measured memory_bytes: 256
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

int main()
{
    long long a, b, c, d;
    std::cin >> a >> b >> c >> d;

    long long num = b - a + 2;

    if (c < d)
    {
        long long tmp = c;
        c = d;
        d = tmp;
    }

    long long c_dim = b / c - (a + (c - 1)) / c + 1;
    long long d_dim = b / d - (a + (d - 1)) / d + 1;

    long long x = c * d;
    long long r = c % d;
    while (r != 0)
    {
        c = d;
        d = r;
        r = c % d;
    }
    x = x / d;
    long long x_dim = b / x - (a + (x - 1)) / x + 1;

    std::cout << b - a + 1 - c_dim - d_dim + x_dim << std::endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d%d",$a,$b);
  if($a > $b){
    $tmp = $a;
    $a = $b;
    $b = $tmp;
  }
  if($a%2 == 0 && $b%2 == 0 || $a%2 == 1 && $b%2 == 1){
    echo ($b+$a)/2;
  }else{
    echo "IMPOSSIBLE";
  }

Measured memory_bytes: 4856
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int count = 0;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k  = 0;k <= c;k++){
                if(500*(i) + 100*(j) + 50*(k)  == x){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

signed main(){
  string s, t; cin >> s >> t;
  vector<vector<ll> > data(26);
  int n = s.size(), m = t.size();
  for(ll i = 0; i < n; i++) data[s[i] - 'a'].push_back(i + 1);
  for(int i = 0; i < m; i++){
    if(data[t[i] - 'a'].empty()){
      cout << -1 << endl;
      return 0;
    }
  }
  for(int i = 0; i < 26; i++) data[i].push_back(INF);
  ll now = 0, ans = 0;
  for(int i = 0; i < m; i++){
    ll x = t[i] - 'a';
    ll num = *upper_bound(data[x].begin(), data[x].end(), now);  
    if(num == INF){
      ans += n - now + data[x][0];
      now = data[x][0];
    }
    else ans += num - now, now = num;
  }
  cout << ans << endl;
}

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

int main (){
    
int H=1,W=1;
cin >> H >> W;

while(H>0&&W>0){
    for(int n=1;n<=H;n++){
        for (int m=1;m<=W;m++){
            cout << '#';
        }
    cout << endl;
    }
    cout << endl;
    cin >> H >> W;
}

return 0;

}



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

int main()
{
    int n,m=INT_MAX;
    int x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        int c=0;
        while(x%2==0)
        {
            c++;
            x/=2;
            if(c>m) break;
        }
        if(c<m) m=c;
    }
    cout<<m<<endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        long N = int.Parse(Console.ReadLine());
        if(N <= 999){
          Console.WriteLine("ABC");
        }else{
          Console.WriteLine("ABD");
        }
        

    }
}


Measured memory_bytes: 13140
#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 argc, char const *argv[])
{
	sync;
	ll n;
	cin >> n;
	ll a[n+5];
	unordered_map<ll, ll> mp;
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
		sum += a[i];
	}
	ll q, b, c;
	cin >> q;
	rep(i, q){
		cin >> b >> c;
		ll num;
		if (mp.find(b) == mp.end()){
			num = 0;
		}
		else{
			num = mp[b];
		}
		mp[b] = 0, mp[c] += num;
		sum = sum + num*(c-b);
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 7932