akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int main(){
    stack<int> YAMA;
    stack<pair<int, long> > MIZU;
    string s;
    long water=0;
    cin >> s;
    
    for (int i = 0; i<s.size(); i++) {
        if (s[i] == '\\') {
            YAMA.push(i);
        }else if (s[i] == '/' && YAMA.size() != 0){
            long W_sum = 0;
                while (MIZU.size() != 0 && YAMA.top() < MIZU.top().first) {
                    W_sum += MIZU.top().second; MIZU.pop();
                }
            MIZU.push(make_pair(YAMA.top(),W_sum + ( i - YAMA.top())));
            water += i - YAMA.top(); YAMA.pop();
        }
    }
    
    vector<long> ANS;
    int mizu = MIZU.size();
    for (int i = 0; i < mizu; i++) {
        ANS.push_back(MIZU.top().second);
        MIZU.pop();
    }
    cout << water << endl;
    cout << mizu;
    for (int i = mizu-1; i>=0; i--) {
        cout << " " << ANS[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m, a, b;
string str;

int main(){
	cin >> n >> m;
	
	vector<vector<ll>> e;
	e.resize(n+1);
	
	for(ll k = 1; k <= m; k++){
		cin  >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	
	string ans = "YES";
	for(ll i = 1; i <= n; i++){
		if(e[i].size()%2 != 0){
			ans = "NO";
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1<<17
int n,dat[2*(MAX_N)-1];

//INT＿MAXで初期化
void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=INT_MAX;
}

void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

int query(int a,int b,int k=0,int l=0,int r=n){
  if(r<=a||b<=l)return INT_MAX;
  if(a<=l&&r<=b)return dat[k];
  else{
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}

int main(){
  int q;
  cin>>n>>q;
  init(n);
  for(int i=0;i<q;i++){
    int com,x,y;
    cin>>com>>x>>y;
    if(com)cout<<query(x,y+1)<<endl;
    else update(x,y);
  }
  return 0;
}



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

using namespace std;

void solve(vector<int> vec) {
	int counter = 0;
	for (int i = 0; i < vec.size(); i++) {
		for (int j = vec.size()-1; j > i; j--) {
			if (vec[j] < vec[j - 1]) {
				swap(vec[j], vec[j - 1]);
				counter++;
			}
		}
	}

	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i];
		if (i != vec.size() - 1) cout << " ";
		else cout << endl;
	}
	cout << counter << endl;
	return;
}

int main() {
	int n;cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];
	solve(vec);
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    string s, msg;
    msg = "yes";
    cin >> s;
    REP(i,s.size()-1){
        FOR(j,i+1,s.size()){
            if(s[i]==s[j]) msg = "no";
        }
    }
    cout << msg << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int b[100];
int a[100][100];
int main() {
    int n,m,c;
    scanf("%d%d%d", &n,&m,&c);
    for (int i = 0; i < m; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int t = 0;
        for (int j = 0; j < m; j++) {
            t += a[i][j] * b[j];
        }
        if (t + c > 0){
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    fact();
    if (abs(N - M) > 1) {cout << 0 << endl; return 0;}
    if (N == M) {
        cout << Mul(2, Mul(F[N], F[M])) << endl;
    } else {
        cout << Mul(F[N], F[M]) << endl;
    }

    return 0;
}


Measured memory_bytes: 16640
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

struct Number {
  int a, b;
};

int main() {
  int n, k;
  cin >> n >> k;
  vector<Number> numbers;
  vector<Number> cand;
  for (int i = 0; i < n; ++i) { 
    int a, b;
    cin >> a >> b;
    numbers.push_back((Number){a, b});
    cand.push_back((Number){a, b});
  }
  ll ans = 0;
  for (int d = 30; d >= 0; --d) {
    vector<Number> ncand;
    int flag = (k>>d)&1;
    // cout << d << " " << flag << endl;
    ll val = 0;
    for (Number &num: cand) {
      int flag2 = (num.a>>d)&1;
      if (flag2) continue;
      ncand.push_back(num);
      val += num.b;
    }
    if (flag) ans = max(ans, val);
    else swap(cand, ncand);
  }
  ll val = 0;
  for (Number &num: cand) {
    val += num.b;
  }
  ans = max(ans, val);
  cout << ans << endl;
}

Measured memory_bytes: 3676
N,K=map(int,input().split())
x=list(map(int,input().split()))

ans=max(x)-min(x)+max(max(x),abs(min(x)))
#print(ans)
for i in range(N-K+1):
    ans=min(ans,x[i+K-1]-x[i]+min(abs(x[i]),abs(x[i+K-1])))
#    print(x[i:i+K],x[i+K-1]-x[i]+min(abs(x[i]),abs(x[i+K-1])))

print(ans)

Measured memory_bytes: 14392
//解説参考

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

int main(){
	int d,n;
	cin>>d>>n;
	
	
	int pon=1;
	for(int i=1;i<=d;i++){
		pon*=100;
	}
	
	
	if(n!=100) cout<<n*pon<<endl;
	else cout<<101*pon<<endl;
	
	
	return 0;
}		

Measured memory_bytes: 256
#include<stdio.h>
int main( )
{
    int h , n , sum=0 ;
    scanf("%d%d" , &h , &n);
    
    int a  ;
    for( int i = 1 ; i <= n ; i++)
    {
        scanf("%d" , &a);
        sum += a ;
    }
    
    if( sum >= h)
        printf("Yes\n");
    else
        printf("No\n");
        
    return 0;
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n) A[i] = i+1;
  vector<int> P(n), Q(n);
  rep(i,n) cin >> P[i];
  rep(i,n) cin >> Q[i];
  
  int count = 0, a, b;
  do {
    count++;
    if (A == P) a = count;
    if (A == Q) b = count;
  } while (next_permutation(A.begin(), A.end()));
  int ans = fabs(a-b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
 
#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
 
typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
 
int main()
{
    ios::sync_with_stdio(false);
 
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
 
    bool ans = false;
    map<PII, int> vis;
    {
        int x = 0, y = 0;
        while (true) {
            vis[PII(x, y)] = true;
 
            if (x == W-1 && y == H-1) {
                ans = true;
                break;
            }
 
            if (x+1 < W && y+1 < H && S[y][x+1] == '#' && S[y+1][x] == '#') break;
            else if (x+1 < W && S[y][x+1] == '#') x++;
            else if (y+1 < H && S[y+1][x] == '#') y++;
            else break;
        }
    }
 
    if (ans) {
        rep(y, H) rep(x, W) {
            if (S[y][x] == '#' && !vis[PII(x, y)]) ans = false;
        }
    }
 
    cout << (ans ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int dis(P s, P t){
  return abs(s.first-t.first)+abs(s.second-t.second);
}

int main(){
  int h, w, d;cin>>h>>w>>d;
  map<int, P> mp;
  rep(i, h)rep(j, w){
  	int a;cin>>a;
    mp[a]=P(i, j);
  }
  vector<int> cost(h*w);
  for(int i=1;i+d<=h*w;i++){
  	cost[i-1]=dis(mp[i], mp[i+d]);
  }
  vector<vector<int>> sum(d, vector<int>());
  rep(i, d){
    int acc=0;
  	for(int j=i+1;j+d<=h*w;j+=d){
      sum[i].push_back(acc);
      acc+=cost[j-1];
    }
    sum[i].push_back(acc);
  }
  
  int q;cin>>q;
  rep(i, q){
  	int l, r;cin>>l>>r;
    int rest=(l-1)%d;r-=rest+1;l-=rest+1;
    cout<<sum[rest][r/d]-sum[rest][l/d]<<endl;
  }
  // for(auto& e: sum[1])cout<<e<<" ";cout<<endl;
  return 0;
}



Measured memory_bytes: 11392
#include<stdio.h>
#include<math.h>
typedef struct{
  double x;
  double y;
}point;
void kock(int,point,point);

int main(){

  int n;
  point p1,p2;

  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}
void kock(int n,point p1,point p2){

  double rad=60.0*M_PI/180.0;
  point s,t,u;
  
  if(n==0) return;
  //p1,p2から s,t,uを計算
  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
  u.y=(t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;

  
  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1,t,p2);
}



Measured memory_bytes: 2104
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[101][101];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N * (N - 1) / 2) + (M * (M - 1) / 2) << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =5e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
struct node{
	int l,r,id;
	bool operator < (const node &o)const
	{
		return r<o.r;
	}
}b[MAXN];
int n,q,a[MAXN],last[MAXN],ans[MAXN],need[MAXN];
void add(int x,int val)
{
	while(x<=n)
	{
		need[x]+=val;
		x+=lowbit(x);
	}
}
int get(int x)
{
	int sum=0;
	while(x)
	{
		sum+=need[x];
		x-=lowbit(x);
	}
	return sum;
}
int main()
{
	scanf("%d %d",&n,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=q;i++)
	{
		scanf("%d %d",&b[i].l,&b[i].r);
		b[i].id=i;
	}
	sort(b+1,b+1+q);
	int r=1;
	for(int i=1;i<=q;i++)
	{
		int rr=b[i].r;
		while(r<=rr)
		{
			if(last[a[r]])	add(last[a[r]],-1);
			add(r,1);
			last[a[r]]=r;
			r++;
		}
		ans[b[i].id]=get(rr)-get(b[i].l-1);
	}
	for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 17400
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')



A, B = list(map(int, input().split()))
if A >=13:
    print(B)
elif A>=6:
    print(B// 2)
else:
    print(0)


Measured memory_bytes: 13556
function main (input) {
  inputList = input.split(' ');
  timeList = [];
  for (input of inputList) {
    timeList.push(parseInt(input, 10));
  }
  min = 0;
  for (s = 0; s < 3; s++) {
    if ((val = timeList[s] + timeList[(s+1) % 3]) < min || min === 0) {
      min = val;
    };
  }
  console.log('%d', min);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

Measured memory_bytes: 7496
import numpy as np
a, b, x = map(int, input().split())
if x <= a*a*b/2:
    print(np.arctan(a*b*b/(2*x))*180/np.pi)
else:
    print(np.arctan((a*a*b - x)/(a*a*a/2))*180/np.pi)

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

int main() {
    // input
    int H, W;
    cin >> H >> W;

    char a[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
        }
    }

    // solve & output
    for (int i = 0; i < H + 2; ++i) {
        for (int j = 0; j < W + 2; ++j) {
            if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
                cout << "#";
            } else {
                cout << a[i - 1][j - 1];
            }
        }
        cout << endl;
    }

    return 0;
}


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

//本当は間違いのコード(提出したら通ってしまった)
int main(){
  int N;
  int t[100010],x[100010],y[100010];
  bool checker = true;
  cin >> N;
  t[0]=x[0]=y[0]=0;
  for (int i = 1; i<=N ;++i)cin>>t[i]>>x[i]>>y[i];
  for (int i = 1; i<=N ;++i){
    int bbt = t[i]-t[i-1];
    //戻っても負にならないように絶対値をとろう
    int bbx = abs(x[i])-abs(x[i-1]);
    int bby = abs(y[i])-abs(y[i-1]);

    //cout<<"t="<<t[i]<<"のとき,x="<<x[i]<<",y="<<y[i]<<endl;
    if((bbt<(bbx+bby)) || ((bbt&1)!=((bbx+bby)&1))){
        //cout<<"条件外です"<<endl;
        checker = false;
        break;
    }
  }
  if(checker)cout <<"Yes"<<endl;
  else cout<<"No"<<endl;

}

Measured memory_bytes: 1408
N,M = [int(x) for x in input().split()]
dict={1:[]}
for _ in range(M):
    a,b = [int(x) for x in input().split()]
    if(a==1):
        dict[1].append(b)
    elif(b==N):
        dict[a]=b
flag = False
for i in dict[1]:
    if(i in dict):
        flag = True
        break
if(flag):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 21256
#include<bits/stdc++.h>
using namespace std;
int N, M;

struct edge{
    int to, tf;
};
vector<edge> G[100010];
bool used[100010];

void dfs(int n){
    used[n] = true;
    for(auto u : G[n]){
        if(!used[u.to]) dfs(u.to);
    }
}

int main(){
    cin >> N  >> M;
    for(int i = 0; i < M; i++){
        int X, Y, Z;
        cin >> X >> Y >> Z;
        int t = 0;
        if(Z % 2 == 1) t = 1;
        G[X].push_back(edge{Y, t});
        G[Y].push_back(edge{X, t});
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(used[i]) continue;
        ans++;
        dfs(i);
    }
    cout << ans << endl;
    return 0;
}


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

long long int N, p[364364], id[364364], dp[364364], x, i;

int main(){
    iota(p, p + 364364, 1);
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", p + i);
        id[p[i]] = i;
    }
    dp[N] = 0;
    x = N;
    for(; --i;){
        if(dp[i + 1]){
            dp[i] = dp[i + 1];
            if((id[i] < id[i + 1]) ^ (id[i + 1] < id[x]) ^ (id[x] < id[i])){
                ++dp[i];
                x = i + 1;
            }
        }else{
            dp[i] = dp[i + 1] + ((id[i] > id[i + 1]) ? 1 : 0);
            if(id[i] < id[i + 1])--x;
        }
    }
    cout << dp[1] << endl;
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

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

int main()
{
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i = 0; i < Q; i++)
    {
        cin >> A[i];
        A[i]--;
    }

    // sort(A.begin(),A.end());
    vector<int> people(N,Q);
    for(int i = 0; i < Q; i++)
    {
        people[A[i]]--;
    }
    int Max = 0;;
    for(int i = 0; i < N; i++)
    {
       if(people[i] < K)
       {
           cout << "Yes" << endl;
       }
       else
       {
           cout << "No" << endl;
       }
    }

}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		int d = saori.saori_hayami();
		if(a+b > c+d){
			System.out.println("Left");
		} else if(a+b < c+d){
			System.out.println("Right");
		} else {
			System.out.println("Balanced");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a*b) / 2 << endl;
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5,MOD=1e9+7;
typedef long long ll;
#define fix(cur) (int((cur%MOD+MOD)%MOD))

struct MODNUM{
	int num;
	MODNUM(){}
	MODNUM(int _num):num(_num){}
	MODNUM operator *(const MODNUM cur)const{return fix(1ll*num*cur.num);}
	MODNUM operator +(const MODNUM cur)const{return fix(1ll*num+cur.num);}
	MODNUM operator -(const MODNUM cur)const{return fix(1ll*num-cur.num);}
	MODNUM operator *=(const MODNUM cur){return *this=(*this)*cur;}
	MODNUM operator +=(const MODNUM cur){return *this=(*this)+cur;}
	MODNUM operator -=(const MODNUM cur){return *this=(*this)-cur;}
}Cfac[2*N+3],Cinv[2*N+3],Cone(1);
MODNUM QPow(MODNUM und,int cur){
	MODNUM resu(1);
	while(cur){
		if(cur&1) resu*=und;
		und*=und;
		cur>>=1;
	}
	return resu;
}
MODNUM fC(int cura,int curb){return Cfac[curb]*Cinv[cura]*Cinv[curb-cura];}

int n,Ia,Ib,Ic;

void Init(){
	Cfac[0]=1;for(int i=1;i<=2*N;i++) Cfac[i]=Cfac[i-1]*i;
	Cinv[2*N]=QPow(Cfac[2*N],MOD-2);for(int i=2*N-1;i>=0;i--) Cinv[i]=Cinv[i+1]*(i+1);
}
int main(){
	Init();
	scanf("%d%d%d%d",&n,&Ia,&Ib,&Ic);
	MODNUM Phaf=QPow(Ia+Ib,MOD-2)*Ia,ans=0,Pc=QPow(100,MOD-2)*Ic;
//	printf("%d\n",Cone);
	for(int i=0;i<n;i++)
		ans+=fC(i,n-1+i)*(QPow(Phaf,n)*QPow(Cone-Phaf,i)+QPow(Phaf,i)*QPow(Cone-Phaf,n))*(i+n)*QPow(Cone-Pc,MOD-2);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
T=list(map(int,input().split()))
N = T[0]
M = T[1]
A = []
B = []
count = 0
num = 0
for i in range(N):
	P=list(map(int,input().split()))
	A.insert(i,P[0])
	B.insert(i,P[1])

d=zip(A,B)
d1 = sorted(d)

for a,b in d1:
	for j in range(b):
		if(count == M):
			break
		count = count + 1
		num = num + a
	else:
		continue
	break
print(num) 

Measured memory_bytes: 18464
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    int fact[1000005];
    bool ok=false;
 
    void f(int x){
        if(ok==true)
            return;
        for(int i=1;i*i<=x;i++){
            if(x%i==0){
                int a=i;
                int b=x/i;
                if(a==b){
                    a=i;
                    b=1;
                }
                if(a!=1){
                    if(fact[a]){
                        ok=true;
                        return;
                    }
                    fact[a]++;
                }
                if(b!=1){
                    if(fact[b]){
                        ok=true;
                        return;
                    }
                    fact[b]++;
                }
            }
        }
    }
 
    void solve(){  
        int n;
        cin>>n;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        int gcd=a[0];
        // cout<<"in "<<ok<<"\n";
        f(a[0]);
        // cout<<"in "<<ok<<"\n";
        for(int i=1;i<n;i++){
            f(a[i]);
            gcd=__gcd(gcd,a[i]);
            // cout<<"in "<<ok<<"\n";
        }
        if(!ok){
            cout<<"pairwise coprime";
        }
        else if(gcd==1){
            cout<<"setwise coprime";
        }
        else{
            cout<<"not coprime";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 7496
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    b = [i >> 1 for i in a]
    c = [i&1 for i in b]
    c.sort()
    while 1:
        if c[0] == 1:
            break
        if c[0] == 0 and c[-1] == 1:
            print(0)
            return
        b = [i >> 1 for i in b]
        c = [i&1 for i in b]
        c.sort()
        m >>= 1
    l = b[0]
    for i in b[1:]:
        if l&1 != i&1:
            print(0)
            return
        g = gcd(l,i)
        l = l*i//g
        if l > m:
            print(0)
            return
    L = l
    l = 0
    r = m+1
    while r-l > 1:
        x = (l+r) >> 1
        if (2*x-1)*L <= m:
            l = x
        else:
            r = x
    print(l)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 118636
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a,b,c=0;
		a=sc.nextInt();
		for(int i=1;i<=a;i++)
		{
			if(String.valueOf(i).length()%2 != 0)
			{c++;}
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 28372
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
    using namespace std;
    #define pii pair<int,int>
    #define fir first
    #define sec second
    #define MP make_pair
    #define rep(i,x,y) for (int i=(x);i<=(y);i++)
    #define drep(i,x,y) for (int i=(x);i>=(y);i--)
    #define go(x) for (int i=head[x];i;i=edge[i].nxt)
    #define templ template<typename T>
    #define sz 101010
    typedef long long ll;
    typedef double db;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
    templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
    templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
    templ inline void read(T& t)
    {
        t=0;char f=0,ch=getchar();double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t=(f?-t:t);
    }
    template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
    char __sr[1<<21],__z[20];int __C=-1,__zz=0;
    inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
    inline void print(register int x)
    {
        if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
        while(__z[++__zz]=x%10+48,x/=10);
        while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
    }
    void file()
    {
        #ifdef NTFOrz
        freopen("a.in","r",stdin);
        #endif
    }
    inline void chktime()
    {
        #ifndef ONLINE_JUDGE
        cout<<(clock()-t)/1000.0<<'\n';
        #endif
    }
    #ifdef mod
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
    ll inv(ll x){return ksm(x,mod-2);}
    #else
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
    #endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,X,Y,Z;
struct hh{ll a,b,c;const bool operator < (const hh &x) const {return b-a<x.b-x.a;}}q[sz];
ll pre[sz],suf[sz];

void getPre()
{
	priority_queue<ll>s;priority_queue<ll,vector<ll>,greater<ll>>t;
	ll cur=0;
	rep(i,1,X) cur+=q[i].a,s.push(q[i].c-q[i].a);
	pre[X]=cur;
	rep(i,X+1,n-Y)
	{
		s.push(q[i].c-q[i].a);cur+=s.top()+q[i].a,t.push(s.top()),s.pop();
		ll x;
		while (s.top()>t.top()) x=s.top(),s.pop(),cur+=x-t.top(),s.push(t.top()),t.pop(),t.push(x);
		pre[i]=cur;
	}
}
void getSuf()
{
	priority_queue<ll>s;priority_queue<ll,vector<ll>,greater<ll>>t;
	ll cur=0;
	drep(i,n,n-Y+1) cur+=q[i].b,s.push(q[i].c-q[i].b);
	suf[n-Y+1]=cur;
	drep(i,n-Y,X+1)
	{
		s.push(q[i].c-q[i].b);cur+=s.top()+q[i].b,t.push(s.top()),s.pop();
		ll x;
		while (s.top()>t.top()) x=s.top(),s.pop(),cur+=x-t.top(),s.push(t.top()),t.pop(),t.push(x);
		suf[i]=cur;
	}
}

int main()
{
    file();
	read(X,Y,Z);n=X+Y+Z;
	rep(i,1,n) read(q[i].a,q[i].b,q[i].c);
	sort(q+1,q+n+1);
	getPre(),getSuf();
	ll ans=-1e18;
	rep(i,X,n-Y) chkmax(ans,pre[i]+suf[i+1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4956
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:-x,a))
heapq.heapify(a)
for i in range(m):
    t = heapq.heappop(a)
    t = -(-t//2)
    heapq.heappush(a,t)
print(sum(a)*-1)

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    vector<vector<int>> C(H, vector<int>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> B[i][j];
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            C[i][j] = A[i][j] - B[i][j];
            if(C[i][j] < 0) C[i][j] *= -1;
        }
    }

    vector<vector<bitset<12801>>> dp(H, vector<bitset<12801>>(W));
    dp[0][0][C[0][0]] = 1;
    for (int i = 1; i < H; ++i) {
        int j = 0;
        for (int k = 0; k < 12801; ++k) {
            if(dp[i-1][j][k] == 0) continue;
            int up = k + C[i][j];
            int dec = k - C[i][j];
            if(dec < 0) dec *= -1;
            dp[i][j][up] = 1;
            dp[i][j][dec] = 1;
        }
    }
    for (int j = 1; j < W; ++j) {
        int i = 0;
        for (int k = 0; k < 12801; ++k) {
            if(dp[i][j-1][k] == 0) continue;
            int up = k + C[i][j];
            int dec = k - C[i][j];
            if(dec < 0) dec *= -1;
            dp[i][j][up] = 1;
            dp[i][j][dec] = 1;
        }
    }
    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            for (int k = 0; k < 12801; ++k) {
                if(dp[i-1][j][k] == 0) continue;
                int up = k + C[i][j];
                int dec = k - C[i][j];
                if(dec < 0) dec *= -1;
                dp[i][j][up] = 1;
                dp[i][j][dec] = 1;
            }
            for (int k = 0; k < 12801; ++k) {
                if(dp[i][j-1][k] == 0) continue;
                int up = k + C[i][j];
                int dec = k - C[i][j];
                if(dec < 0) dec *= -1;
                dp[i][j][up] = 1;
                dp[i][j][dec] = 1;
            }
        }
    }
    int ans;
    for (int i = 0; i < 12801; ++i) {
        if(dp[H-1][W-1][i] == 1){
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int n, d, a, b;

int main() {
	cin >> n >> d;
	a=2*d+1;
	if (n%a==0) {
		b=n/a;
	}
	else {
		b=n/a + 1;
	}
	cout << b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std;

const int N=17,mod=1e9+7;
int n,m,ans,a[N],f[N+1][1<<N],c[1<<N],fac[1<<N],inv[1<<N];

void inc(int &x,int y){ x=(x+y>=mod) ? x+y-mod : x+y; }

int C(int n,int m){ return n<m ? 0 : 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod; }

int ksm(int a,int b){
	int res=1;
	for (; b; a=1ll*a*a%mod,b>>=1)
		if (b & 1) res=1ll*res*a%mod;
	return res;
}

int main(){
	scanf("%d%d",&n,&m); c[0]=fac[0]=1; f[m+1][0]=1;
	rep(i,1,1<<n) fac[i]=1ll*fac[i-1]*i%mod;
	inv[1<<n]=ksm(fac[1<<n],mod-2);
	for (int i=1<<n; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	rep(i,1,1<<n) c[i]=(i&1)?mod-c[i>>1]:c[i>>1];
	rep(i,1,m) scanf("%d",&a[i]); sort(a+1,a+m+1);
	for (int i=m; i; i--) rep(t,0,(1<<n)-1) if (f[i+1][t]){
		inc(f[i][t],f[i+1][t]);
		rep(j,0,n-1) if (!(t&(1<<j))) inc(f[i][t|(1<<j)],1ll*C((1<<n)-t-a[i],(1<<j)-1)*f[i+1][t]%mod*fac[1<<j]%mod);
	}
	rep(i,0,(1<<n)-1) inc(ans,1ll*f[1][i]*fac[(1<<n)-1-i]%mod*c[i]%mod);
	printf("%lld\n",1ll*ans*(1<<n)%mod);
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  int n;
  while(cin >> n, n) {
    int height[5] = {}; // ツ各ツ療アツづ可堕カツ催敖つキツづゥツブツδ債ッツクツづ個暗ェツ氾板湘」ツづ個暗ェツ古つ湘」
    bool ba[5][5010] = {};

    while(n--) {
      int d, p, q;
      cin >> d >> p >> q;
      q--;
      if (d == 1) {
        int ma = 0;
        for (int i=q; i<p+q; ++i) {
          ma = max(ma, height[i]);
        }
        for (int i=q; i<p+q; ++i) {
          ba[i][ma] = 1;
          height[i] = ma + 1;
        }
        bool f = 1;
        REP(i,5)
          if (!ba[i][ma])
            f = 0;
        if (f) {
          REP(i,5) {
            for (int j=ma+1; j<height[i]; ++j)
              if (j>0)
                ba[i][j-1] = ba[i][j];
            ba[i][height[i]-1] = 0;
            while(height[i] > 0 && !ba[i][height[i]-1])
              height[i]--;
          }
        }
      } else {
        REP(i,p) {
          ba[q][height[q]+i] = 1;
        }
        height[q] += p;
        for (int k=height[q]-p; k<height[q]; ++k) {
          bool f = 1;
          REP(i,5)
            if (!ba[i][k])
              f = 0;
          //    cout << k << " " << f << endl;
          if (f) {
            REP(i,5) {
              for (int j=k+1; j<height[i]; ++j) {
                if (j > 0)
                  ba[i][j-1] = ba[i][j];
              }
              ba[i][height[i]-1] = 0;
              while(height[i] > 0 && !ba[i][height[i]-1])
                height[i]--;
            }
            // REP(i,10) {
            //   REP(j,5) {
            //     cout << ba[j][9-i];
            //   }
            //   cout << endl;
            // }
            // cout << endl;
            k--;
          }
        }
      }
      // REP(i,10) {
      //   REP(j,5) {
      //     cout << ba[j][9-i];
      //   }
      //   cout << endl;
      // }
      // REP(i,5)
      //   cout << height[i] << " ";
      // cout << endl << endl;;
    }
    int ans = 0;
    REP(i,5)
      REP(j,5010)
        if (ba[i][j])
          ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>

using namespace std;

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   for(int i=1;i<=b;i++){
      int tmp=a*i-c;
      if(tmp%b==0){
         cout<<"YES"<<endl;
         return 0;
      }
   }
   cout<<"NO"<<endl;

}

   


Measured memory_bytes: 256
NUM_PUSH = 2


def main():
    A, B = map(int, input().split())
    sum = 0
    for i in range(NUM_PUSH):
        if A >= B:
            push = A
            A -= 1
        else:
            push = B
            B -= 1
        sum += push
    print(sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
 
const int L=200*1000;
P bs[L];
int N;
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		int x,y;
		cin >> x >> y;
		if(x>y){
			swap(x,y);
		}
		bs[i]=P(x,y);
	}
	sort(bs,bs+N);
	int r0,r1,b0,b1;
	r0=bs[0].first;
	r1=bs[N-1].first;
	b0=b1=bs[0].second;
	for(int i=1;i<N;i++){
		b0=min(b0,bs[i].second);
		b1=max(b1,bs[i].second);
	}
	LL ret=(r1-r0)*(LL)(b1-b0);
	//cerr << ret << endl;
	r1=b1;
	int m0,m1;
	m0=m1=bs[0].second;
	//cerr << r0 << ", " << r1 << endl;
	for(int i=1;i<N;i++){
		b0=min(bs[i].first,m0);
		b1=max(bs[N-1].first,m1);
		//cerr << b0 << ": " << b1 << endl;
		ret=min(ret,(r1-r0)*(LL)(b1-b0));
		m0=min(m0,bs[i].second);
		m1=max(m1,bs[i].second);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, a, b) for(int i=(a); i<(int)(b); i++)

typedef long long ll;

using namespace std;

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

int main(void){
	int n, k; cin >> n >> k;
	double ans = 0.0;
	rep2(i, 1, n+1){
		int tmp = i;
		double prob = 1.0/n;
		while(tmp < k){
			tmp *= 2;
			prob /= 2.0;
		}
		ans += prob;
	}
	printf("%.10f\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int n, h;
	scanf ("%d", &n);
	h = n / 100;
	if (n <= 111*h) {
		printf ("%d\n", 111*h);
	} else {
		printf ("%d\n", 111*(h+1));
	}
	return 0;
}


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

const int maxn = 2e5+5;


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    deque<int> ans;
    for (int i = 0; i < n; i++) {
        int ai; cin >> ai;
        if (i % 2 == 0) ans.push_back(ai);
        else ans.push_front(ai);
    }
    if (n&1) reverse(ans.begin(),ans.end());
    for (int i: ans) {
        cout << i << ' ';
    }
    cout << '\n';
}



Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 100000000;
typedef pair<ll, ll> P;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
char c[25][25];
int h, w;

int bfs(int x, int y) {
	int dist[25][25];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = inf;
		}
	}
	dist[x][y] = 0;
	queue<P>q;
	q.push({ x,y });
	while (q.size()) {
		P now = q.front();
		q.pop();
		for (int k = 0; k < 4; k++) {
			int nextx = now.second + dx[k];
			int nexty = now.first + dy[k];
			if (nextx >= 0 && nextx < w && nexty >= 0 && nexty < h && dist[nexty][nextx] == inf && c[nexty][nextx]=='.') {
				dist[nexty][nextx] = dist[now.first][now.second]+1;
				q.push({ nexty,nextx });
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (dist[i][j] != inf) {
				ans = max(ans, dist[i][j]);
			}
		}
	}
	return ans;
}
int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	ll kai = 0;
	ll ans;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (c[i][j] == '.') {
				ans = bfs(i, j);
				kai = max(kai, ans);
			}
		}
	}
	cout << kai << endl;
	return 0;
}

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

int ans, cnt[12], len;
long long n, mul = 1, p[12];

void split(long long n){
	len = 0;
	for(int i = 2; 1ll * i * i <= n; i++) if(n % i == 0){
		p[len] = i, cnt[len] = 0;
		do n /= i, cnt[len]++; while(n % i == 0);
		len++;
	}
	if(n != 1) cnt[len] = 1, p[len++] = n;
}

void dfs(int i){
	if(i == len){
		if(mul == 1) return;
		long long tmp = n;
		do tmp /= mul; while(tmp % mul == 0);
		ans += tmp % mul == 1;
		return;
	}
	dfs(i + 1);
	for(int j = 0; j < cnt[i]; j++)
		mul *= p[i], dfs(i + 1);
	for(int j = 0; j < cnt[i]; j++) mul /= p[i];
}

int main(){
	scanf("%lld", &n);
	split(n), dfs(0), split(n - 1);
	for(int i = 0; i < len; i++) mul *= cnt[i] + 1;
	printf("%lld", ans + mul - 1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)
 
 
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
int main(){
    ll x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
#include <cstring>
int main() {
	int n;
	std::cin >> n;
	std::vector<std::string>w(n);
	std::vector<int>si(n);
	for (int i = 0;i < n;++i) {
		std::cin >> w[i];
		si[i] = w[i].size();
		
	}
	


	for (int i = 0;i < (n - 1);++i) {
		if (w[i][si[i] - 1] != w[i + 1][0]) {
			std::cout << "No" << std::endl;
			return 0;
		}

	}
	for (int i = 0;i < n;++i) {

		for (int f = 0;f < i;++f) {
			if (w[i] == w[f]) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	
	std::cout << "Yes" << std::endl;

		return 0;
	
}



Measured memory_bytes: 256
//繝・Φ繝励Ξ
#include <bits/stdc++.h>
#define int long long
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PAIR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 

  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N, Y;
  cin >> N >> Y;
  REP(x,N + 1)
  {
    REP(y,N -x + 1)
    {
      if(x * 10000 + y * 5000 + (N - x- y) * 1000 == Y)
      {
        cout << x << " " << y << " " << N - x-y << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
}

//N縺薙・荳ｭ縺九ｉ騾｣邯壹☆繧橘蛟九ｒ驕ｸ縺ｶ縺ｨ縺阪・驕ｸ縺ｳ譁ｹ縺ｯ髯舌ｌ繧峨ｌ繧九・ S T L

//驛ｨ蛻・・譛蟆丞､
//譖ｴ譁ｰ縺励↑縺・ｴ蜷遺・邏ｯ遨阪ｏ REP(i,N) ruiseki[i+1] += ruiseki[i];
//莠梧ｬ｡蜈・↓縺励◆縺・・縺・ｂ縺呎ｳ・
//荳邂・園繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Segment Tree(縺溘□縺怜叙蠕涌(logN))
//遽・峇繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Lazy Segment Tree


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    double x = (n - d) * 2.0;
    if (d == 0) x = n;
    double a = (m - 1.0) / n;
    double b = x / n;
    printf("%.12lf\n", a * b);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void bigswap(int *a,int *b){
if(*a > *b){
int temp = *a;
*a = *b;
*b =temp;
}

}


int main(void){
    int a,b;
    

    int i = 0;
    for(; i<3000; i++){
        scanf("%d %d", &a, &b);
        if(a==0 && b == 0){
            break;
        }
        bigswap(&a,&b);
        printf("%d %d\n",a,b);
    }
    
    return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;


const int INF=10000000;
int ans;
int n,m;
int r;
int load[201][201];
int sea[201][201];
int dp[1001][201];
int rt[1001];
int main(void){
	while(1){
		for(int i=0;i<=200;i++){
			for(int j=0;j<=200;j++){
				load[i][j]=sea[i][j]=INF;
			}
			load[i][i]=sea[i][i]=0;
			for(int j=0;j<=1000;j++){
				dp[j][i]=INF;
			}
		}
		cin >> n >> m;
		if(n==0 && m==0)break;
		for(int i=0;i<m;i++){
			int a,b,ti;
			string ls;
			cin >> a >> b >> ti >> ls;
			a--,b--;
			if(ls=="L"){
				load[a][b]=min(load[a][b],ti);
				load[b][a]=min(load[b][a],ti);
			}
			if(ls=="S"){
				sea[a][b]=min(sea[a][b],ti);
				sea[b][a]=min(sea[b][a],ti);
			}
		}
		for(int k=0;k<=200;k++){
			for(int i=0;i<=200;i++){
				for(int j=0;j<=200;j++){
					load[i][j]=min(load[i][j],load[i][k]+load[k][j]);
					sea[i][j]=min(sea[i][j],sea[i][k]+sea[k][j]);
				}
			}
		}
		cin >> r;
		for(int i=0;i<r;i++){
			cin >> rt[i];
			rt[i]--;
		}
		dp[0][rt[0]]=0;
		//配達先
		for(int i=0;i<r-1;i++){
			//次の船の位置
			for(int j=0;j<=200;j++){
				//今の船の位置
				for(int k=0;k<=200;k++){
					if(dp[i][k]!=INF){
						dp[i+1][j]=min(dp[i+1][j],dp[i][k]+load[rt[i]][k]+sea[k][j]+load[j][rt[i+1]]);
						if(j==k)dp[i+1][j]=min(dp[i+1][j],dp[i][k]+load[rt[i]][rt[i+1]]);
					}
				}
			}
		}
		int res=INF;
		for(int i=0;i<=200;i++)res=min(res,dp[r-1][i]);
		printf("%d\n",res);
	}
	return 0;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  vector<int> vec(5) ;
  int k ;
  rep(i, 5){
    cin >> vec.at(i) ;
  }
  cin >> k ;
  sort(vec.begin(),vec.end()) ;
  
  if(vec.at(4)-vec.at(0)<=k){
    cout <<"Yay!"<<endl ;
  }
  else{
    cout <<":("<<endl ;
  }
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256