akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy" << endl;
    else if(s == "Cloudy")
        cout << "Rainy" << endl;
    else if(s == "Rainy")
        cout << "Sunny" << endl;

    return 0;
}

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

int x, y, z, k;
ll a[1111], b[1111], c[1111];

bool f(ll n) {
    int cnt = 0;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            for (int l = 0; l < z; l++) {
                if (a[i] + b[j] + c[l] < n) break;
                cnt++;
                if (cnt >= k) return true;
            }
        }
    }
    return false;
}

int main() {
    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    sort(a, a + x, greater<ll>());
    sort(b, b + y, greater<ll>());
    sort(c, c + z, greater<ll>());
    ll lb = -1, ub = 1001001001001;
    while (ub - lb > 1) {
        ll md = (ub + lb) / 2;
        if (f(md)) lb = md;
        else ub = md;
    }
    priority_queue<ll> que;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            for (int l = 0; l < z; l++) {
                if (a[i] + b[j] + c[l] < lb) break;
                que.push(a[i] + b[j] + c[l]);
            }
        }
    }
    for (int i = 0; i < k; i++) {
        if (que.empty()) {
            cout << lb << endl;
        } else {
            cout << que.top() << endl;
            que.pop();
        }
    }
}

Measured memory_bytes: 134468
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int x;cin>>x;
  int tmp = 0;
  if(x == 1){
    cout << 1 << endl;
    return 0;
  }
  for(int i = 2; 32 > i; i++){
    for(int j = 2; x >= pow(i,j); j++){
      int f = pow(i,j);
      tmp = max(tmp,f);
    }
  }
  cout << tmp << endl;
}

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

int main(void) {
    int N;
    double M;
    cin >> N >> M;

    double A[N];
    double cnt=0.0;
    for(int i=0; i<N; i++){
      cin >> A[i];
      cnt += A[i];
     }

     double tmp;
     tmp = cnt/(4ll*(double)M);



     sort(A,A+N);
     reverse(A,A+N);
     bool flag = true;
     int tmp2 = M;
     for(int i=0; i<tmp2; i++){
       if(A[i]<tmp)
        flag = false;
     }

    if(flag)
      cout << "Yes" << endl;
      else
      cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
loop_flags = [False] * N
loops = []
for i in range(N):
    if loop_flags[i]:
        continue
    next_cell = i
    loop = []
    while not loop_flags[next_cell]:
        loop_flags[next_cell] = True
        loop.append(C[next_cell])
        next_cell = P[next_cell] - 1
    if loop:
        loops.append(loop)
# print(loops)
ans = C[0]
for loop in loops:
    work_loop_sum = []
    now = 0
    tmp_ans = 0
    one_loop_point = sum(loop)
    if one_loop_point <= 0 or K <= len(loop):
        for i in range(1, min(K + 1, len(loop) + 1)):
            tmp_ans = sum(loop[:i])
            for j in range(len(loop)):
                ans = max(tmp_ans, ans)
                tmp_ans = tmp_ans - loop[j] + loop[(i + j) % len(loop)]
    else:
        for i in range(min(K + 1, len(loop) + 1)):
            tmp_ans = sum(loop[:i]) + ((K - i) // len(loop)) * one_loop_point
            for j in range(len(loop)):
                ans = max(tmp_ans, ans)
                tmp_ans = tmp_ans - loop[j] + loop[(i + j) % len(loop)]

print(ans)

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

using namespace std;

typedef long long ll;
ll h[100005];
ll n,a,b;

bool check(ll k){
    ll cnt = k*b;
    int num = upper_bound(h+1,h+1+n,cnt) - h;
    ll sum = 0;
    for(int i = num;i <= n;i++)
    {
        //printf("h[i]=%lld\n",h[i]);
        ll tmp = h[i] - cnt;
        sum += (tmp+a-b-1) / (a-b);
        //tmp/(a-b)+bool(tmp%(a-b));
    }
    //printf("%lld %lld\n",sum,k);
    return sum <= k;
}
int main(){
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i = 1;i <= n;i++)
        scanf("%lld",&h[i]);

    sort(h+1,h+1+n);
    ll l = 0,r = INT_MAX,mid;
    while(l < r){
        mid = (l+r)/2;
        if(!check(mid))
            l = mid+1;
        else
            r = mid;
    }
    printf("%lld\n",r);
    return 0;
}
//2 3   2 3  1 2  1 1       5 5 3 5


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define setA0(a) for(ull i =0;i<n;i++){a[i] = 0;}
#define aout(a) for(auto x : a){cout<<x<<' ';} 
#define ain(a) for(ull i =0;i<n;i++){cin>>a[i];}
#define NofSetBits(x) __builtin_popcount(x);
#define InpGrph(g,e) while(e--){ll x;ll y;cin>>x>>y ;g[x].pub(y);g[y].pub(x);}
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);




int main(){
  FastIO;
  ll n;
  cin>>n;
  ll a[n];
  ll prfx[n+1];
  for(ll &x : prfx){
    x =0;
  }
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  prfx[0] = a[0];
  for(ll i=1;i<n;i++){
    prfx[i] = a[i]+prfx[i-1];
  }
  ull sum =0;
  for(ll i=0;i<n-1;i++){
    sum = (sum%mod + ((a[i]%mod*((prfx[n-1] - prfx[i])%mod))))%mod;
  }
  cout<<sum;


  return 0;
} 




Measured memory_bytes: 6756
import std.stdio;
import std.conv;
import std.string;
import std.format;

void compare(int a, int b) {

  if ( a == b ) {
    writefln("a == b");
  } else if (a > b) {
    writefln("a > b");
  } else {
    writefln("a < b");
  }
}

void main()
{
  string s = chomp(readln());
  int a = to!int(s.split(" ")[0]);
  int b = to!int(s.split(" ")[1]);
  compare(a, b);
}

Measured memory_bytes: 2480
n, p = map(int,input().split())
ans = 1
if n == 1:
  ans = p
elif n > 40:
  pass
else:
  i = 1
  while(True):
    t = i ** n
    if t > p:
      break
    if p % t == 0:
      ans = i
    i += 1
print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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;}
int const INF = 1 << 30;


int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<ll> v;
    v.push_back(a*c);
    v.push_back(a*d);
    v.push_back(b*c);
    v.push_back(b*d);
    ll res = *max_element(all(v));
    if(a <= 0 && 0 <= b) chmax(res,(ll)0);
    if(c <= 0 && 0 <= d) chmax(res,(ll)0);
    cout << res << endl;
    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    sort(a, a + n, greater<int>());
    long long ret = 0;
    for (int i=0, j=0; i<n; i++) {
        ret += a[j];
        if (i % 2) j++;
    }

    cout << ret - a[0] << "\n";

    return 0;
}


Measured memory_bytes: 4404
n = int(input())
a = [int(x) for x in input().split()]
count = 0

for i in range(n):
    min_index = i
    
    for j in range(i+1, n):
        if a[j] < a[min_index]:
            min_index = j
            
    if i != min_index:
        a[i], a[min_index] = a[min_index], a[i]
        count += 1

print(' '.join([str(x) for x in a]))
print(count)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
int main(){
	string s;
	cin>>s;
	int len=s.size(),f1=0;
	string s1=s,s2="",s3="";
	reverse(s1.begin(),s1.end());
	int r1=(len-1)/2,l2=(len+3)/2-1;
	for(int i=0;i<r1;i++)s2+=s[i];
	string ss2=s2;
	reverse(s2.begin(),s2.end());
	if(s1!=s||s2!=ss2)f1=1;
	if(f1)cout<<"No";
	else cout<<"Yes";
	return 0;
} 

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

using namespace std;

long long sumFirst(const vector<pair<long long, long long>>& vp){
    long long res = 0;
    for(auto& p : vp) res += p.first;
    return res;
}

int main(){
    int n;
    while(cin >> n){
        vector<pair<long long, long long>> in(n);
        vector<pair<long long, long long>> out(n);
        for(int i=0;i<n;i++){
            cin >> in[i].first; in[i].second = i;
            cin >> out[i].first; out[i].second = i;
        }
        sort(in.begin(), in.end());
        sort(out.begin(), out.end());
        long long res = min(sumFirst(in), sumFirst(out));
        vector<int> hold(n, 0);
        int holdNum = 0;
        auto push = [&](int idx){
            hold[idx]++;
            if(hold[idx] == 1) ++holdNum;
        };
        auto pop = [&](int idx){
            hold[idx]--;
            if(hold[idx] == 0) --holdNum;
        };
        long long sumIn = 0;
        long long sumOut = 0;
        for(int i=0;i<n;i++){
            sumOut += out[i].first;
            push(out[i].second);
        }
        for(int i=0;i<n-1;i++){
            sumOut -= out[n-1-i].first;
            pop(out[n-1-i].second);
            sumIn += in[i].first;
            push(in[i].second);
            if(holdNum < n){
                res = min(res, sumIn + sumOut);
            } else {
                res = min(res, sumIn + sumOut + min(in[i+1].first - in[i].first, out[n-1-i].first - out[n-2-i].first));
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>

using namespace std;

int main() {
int a[7];

int n;
string c;
cin>>n;

while(n!=0){
	for(int j=1;j<7;j++){
	a[j]=j;
}
int sum=1;
for(int k=0;k<n;k++){
cin>>c;
if(c=="North"){
	int q=a[1];
	a[1]=a[2];
	a[2]=a[6];
	a[6]=a[5];
	a[5]=q;
}
if(c=="South"){
		int q=a[1];
	a[1]=a[5];
	a[5]=a[6];
	a[6]=a[2];
	a[2]=q;
}
if(c=="East"){
		int q=a[1];
	a[1]=a[4];
	a[4]=a[6];
	a[6]=a[3];
	a[3]=q;
}	
if(c=="West"){
		int q=a[1];
	a[1]=a[3];
	a[3]=a[6];
	a[6]=a[4];
	a[4]=q;
}	
if(c=="Right"){
		int q=a[2];
	a[2]=a[3];
	a[3]=a[5];
	a[5]=a[4];
	a[4]=q;
	
}
if(c=="Left"){
		int q=a[2];
	a[2]=a[4];
	a[4]=a[5];
	a[5]=a[3];
	a[3]=q;
}
	sum=sum+a[1];

}
cout<<sum<<endl;	
cin>>n;
}

	return 0;
}

Measured memory_bytes: 1208
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define oo (int)1e9
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e3 + 5, M = 2 * N + 5;

int a[N];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    int sum = 0;
    for(int i = 0 ; i < n ; ++i)
        for(int j = i + 1 ; j < n ; ++j)
            sum += (a[i] * a[j]);
    printf("%d\n", sum);
}

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

int main() {
	int n;
	cin >> n;
	int a[3 * n];
	for (int i = 0; i < 3 * n; i++) cin >> a[i];
	long long b[n + 1] = { 0 }, c[n + 1] = { 0 };
	priority_queue<int, vector<int>, greater<int>> pque;
	priority_queue<int> qque;
	for (int i = 0; i < n; i++) {
		b[0] += a[i];
		pque.push(a[i]);
	}
	for (int i = 0; i < n; i++) {
		pque.push(a[i + n]);
		int x = pque.top();
		b[i + 1] = (b[i] + a[i + n] - x);
		pque.pop();
	}
	for (int i = 0; i < n; i++) {
		c[n] += a[3 * n - 1 - i];
		qque.push(a[3 * n - 1 - i]);
	}
	for (int i = 0; i < n; i++) {
		qque.push(a[2 * n - 1 - i]);
		int x = qque.top();
		c[n - 1 - i] = (c[n - i] + a[2 * n - 1 - i] - x);
		qque.pop();
	}
	long long ans = b[0] - c[0];
	for (int i = 1; i <= n; i++) {
		ans = max(ans, b[i] - c[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
string s[100005];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+N);
    int cnt=0;
    for(int i=1;i<N;++i){
        if(s[i]!=s[i-1])cnt=0;
        else cnt++;
        ans+=cnt;
    }
    cout<<ans<<endl;
}


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

int main()
{
    int f=0;
    ll n,k;
    cin>>n>>k;
    int a[n+1],i;
    for(i=1; i<=n; i++)
        cin>>a[i];

    int l,r;
    l=a[1];
    r=a[k];

    int j=1;
    for(i=k+1; i<=n; i++)
    {
        j++;
        ll l1=a[j];
        ll r1=a[i];

        if(r1>l)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }

        l=l1; r=r1;
    }
    return 0;
}


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

int main()
{
    int n, index, w, idx = 0, mx = -1;
    cin >> n;

    for(int i=0;i < n; ++i) {
        cin >> index >> w;
        if (mx < w || (mx == w && idx > index)) idx = index, mx = w;
    }

    cout << idx << " " << mx << endl;

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
  
typedef pair<double,double> P;
typedef pair<P,double> P2;
  
int n;
int a[90];

bool used[90];

int main(){
  cin>>n;
  r(i,n)cin>>a[i];
  r(i,n)if(a[i]==2)used[i]=1;
  r(k,100){
    int ans=1;
    int y=-1,xx=-1;
    for(int i=0;i<n;i++)if(!used[i]){
      for(int j=i+1;j<n;j++)if(!used[j]){
        int x=a[i]*a[j];
        if(ans<x){
          ans=x;
          y=i;
          xx=j;
        }
      }
    }
    if(ans!=1){
    used[xx]=1;
    used[y]=1;}
  }
  int sum=0;
  r(i,n)if(used[i])sum++;
  cout<<sum<<endl;
  r(i,n)if(used[i])cout<<i+1<<endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false;

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

  double a, b;
  int h, m;
  cin >> a >> b >> h >> m;
  
  double th_h, th_m;
  th_h = 2.0 * M_PI * (60 * h + m) / 720.0;
  th_m = 2.0 * M_PI * m / 60.0;

  //cout << th_h << " " << th_m << endl;

  cout << fixed << setprecision(10) << sqrt(a*a + b*b - 2*a*b*cos(th_h - th_m)) << endl;
} 

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

int main() {
    int N,i,c=0;
    string S;
    cin >> N >> S;

    for(i=0; i<N-2; i++)
        if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C')
            c++;
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int n,k;
	cin >>n>>k;
	long long int cnt=0;
	for (int i=1;i<=n;++i){
		cnt+=(n/i)*max(i-k,0);
		cnt+=max(0,(n%i)-(k-1));
	}
	if (k==0)
		cnt-=n;
	cout <<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)
 
int main() {
  int n,sum=0,ans;
  cin>>n;
  
  vector<int> s;
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    sum+=tmp;
    s.emplace_back(tmp);
  }
  
  sort(s.begin(),s.end());
  if(sum%10!=0){cout<<sum<<endl;return 0;}
  
  rep(i,0,n){
    ans=sum;
    ans-=s[i];
    if(ans%10!=0){cout<<ans<<endl;return 0;}
  }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    int A, B, T;
    cin >> A >> B >> T;

    cout <<  (T / A) * B  << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

stock = 0
prop = 1000
grad = -1

for i in range(n - 1):
    diff = a[i + 1] - a[i]
    if grad == -1 and diff > 0:
        trade_num = prop // a[i]
        stock = trade_num
        prop -= (trade_num * a[i])
        grad = 1
    elif grad == 1 and diff < 0:
        prop += stock * a[i]
        stock = 0
        grad = -1
if grad == 1:
    prop += stock * a[n - 1]

print(prop)

Measured memory_bytes: 9208
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int a = scan.nextInt();
	int b = scan.nextInt();
	int c = scan.nextInt();

	if((a < c && c < b) || (b < c && c < a)){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
	
	
    }
}


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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), p = sc.nextInt();
        System.out.println((a * 3 + p) / 2);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int Q; cin >> Q;
	priority_queue<int, vector<int>, less<int>> lows;
	priority_queue<int, vector<int>, greater<int>> highs;
	ll val = 0;
	for (int q = 0; q < Q; q++) {
		int t; cin >> t;
		if (t == 1) {
			int a, b; cin >> a >> b;
			val += b;
			if (lows.empty()) {
				lows.push(a);
			} else {
				val += abs(a - lows.top());
				if (a <= lows.top()) {
					lows.push(a);
					if (lows.size() == highs.size() + 2) {
						highs.push(lows.top());
						lows.pop();
					}
				} else {
					highs.push(a);
					if (lows.size() == highs.size() - 1) {
						val -= highs.top() - lows.top();
						lows.push(highs.top());
						highs.pop();
					}
				}
			}
			assert(int(lows.size()) - int(highs.size()) <= 1);
		} else {
			cout << lows.top() << ' ' << val << '\n';
		}
	}

	return 0;
}


Measured memory_bytes: 3452
import scala.io.StdIn

object Main {
   def main(args: Array[String]) = {
      val Array(n, ty) = StdIn.readLine().split(' ').map(_.toLong)
      val y = ty / 1000
      // 10 5 1
      var t = -1L
      var f = 0L
      var ng = true
      //println("y:" + y)
      while (t <= n && ng) {
         t += 1
         f = n - t
         while (f >= 0 && ng) {
            val r = y - (t * 10 + f * 5)
            //println("r:" + r)
            //println("a:" + (n - (t + f)))
            if (0 <= r && r == n - (t + f)) {
               ng = false
            } else {
               f -= 1
            }
         }
      }
      val result = if (ng) (-1, -1, -1) else (t, f, n - t - f)
      println(result._1 + " " + result._2 + " " + result._3)
   }
}

Measured memory_bytes: 27188
#include <iostream>
using namespace std;
typedef long long ll;
ll n,C,a[100002],b[100002],c[100002],d[100002],dis[100001],ene[100001],ans;
int main(void){
    cin>>n>>C;
    for(int i=1;i<=n;i++){
        cin>>dis[i]>>ene[i];
    }
    for(int i=1;i<=n;i++){
        a[i]=a[i-1]+dis[i-1]-dis[i]+ene[i];
        b[i]=a[i]-dis[i];
    }
    dis[n+1]=C;
    for(int i=n-1;i>=0;i--){
        c[i]=c[i+1]+C-dis[i+2]-C+dis[i+1]+ene[i+1];
        d[i]=c[i]-C+dis[i+1];
        //cout<<c[i]<<endl;
    }
    //for(int i=1;i<=n+1;i++)cout<<a[i-1]<<" "<<b[i-1]<<" "<<c[i-1]<<" "<<d[i-1]<<endl;
    for(int i=1;i<=n;i++){
        a[i]=max(a[i],a[i-1]);
        b[i]=max(b[i],b[i-1]);
        c[n-i]=max(c[n-i],c[n-i+1]);
        d[n-i]=max(d[n-i],d[n-i+1]);
    }
    for(int i=0;i<=n;i++){
        ans=max(ans,a[i]+d[i]);
        ans=max(ans,b[i]+c[i]);
    }
    cout<<ans<<endl;
}


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

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

const int MAXN = 5e5;

int N, M;
ll A[MAXN+10], B[MAXN+10], K;

int main()
{
	int i, j;

	scanf("%d%d%lld", &N, &M, &K);
	for(i=1; i<=N; i++) scanf("%lld", &A[i]), A[i]+=A[i-1];
	for(i=1; i<=M; i++) scanf("%lld", &B[i]), B[i]+=B[i-1];
	int ans=0;
	for(i=0; i<=N && A[i]<=K; i++) ans=max(ans, i+(int)(upper_bound(B, B+M+1, K-A[i])-B-1));
	printf("%d\n", ans);
}

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

int main()
{
  int64_t w, h, x, y;
  double ans1 = 0.0;
  bool ans2 = 0;
  cin >> w >> h >> x >> y;
  ans1 = (double)(w * h / 2.0);
  ans2 = (x + x == w) and (y + y == h);
  cout << setprecision(9) << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
map<string,int>mp;
int n;
int cnt = 0;
cin >> n;
for(int i=0;i<n;i++){
    string s;
    cin >> s;
    auto itr = mp.find(s);        // "xyz" が設定されているか？
    if( itr != mp.end() ) {
        continue;
    } else {
     cnt++;
     mp[s] = cnt;   
    }
}
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 19224
// Aizu Vol-2 0279: A Pair of Prizes
// 2017.8.22 bal4u@uu

#include <stdio.h>

int main()
{
	int N, k;
	int one, many;

	while (scanf("%d", &N) && N) {
		one = many = 0;
		while (N--) {
			scanf("%d", &k);
			if (k == 1) one++;
			else if (k > 1) many++;
		}
		if (many == 0) puts("NA");
		else printf("%d\n", one + many + 1);
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int l[500001],r[500001];
int main (){
  string s;
  cin>>s;
  int i;
  long long int sum=0;
  for(i=0;i<s.length();i++){
    if(s[i]=='<')l[i+1]=l[i]+1;
  }
  for(i=s.length()-1;i>=0;i--){
    if(s[i]=='>')r[i]=r[i+1]+1;
  }
  for(i=0;i<=s.length();i++){
    sum+=max(r[i],l[i]);
  }
  cout<<sum<<endl;
  return 0;
}
  


Measured memory_bytes: 4740
#include <string>
#include <unordered_set>
#include <vector>
#include <cstdio>

int main(){
    int n;
    std::scanf("%d", &n);

    std::unordered_set<std::string> dic;
    std::vector<int> res;
    for(int i = 0; i < n; ++i){
        char opc[10];
        std::scanf("%s", opc);
        char strc[13];
        std::scanf("%s", strc);
        std::string op(opc);
        std::string str(strc);
        if(op == "insert"){
            dic.insert(str);
        } else if(op == "find"){
            if(dic.find(str) != dic.end()){
                res.push_back(1);
            } else {
                res.push_back(0);
            }
        }
    }
    for(auto iter = res.begin(); iter != res.end(); ++iter){
        if(*iter == 1) std::printf("yes\n");
        else std::printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 30188
#include<iostream>
using namespace std;
int main()
{
	int a=0 ,b=0 ,z=0;
	char c;
	cin>>a>>c>>b;
	if(c=='+')
	{
		z=a+b;
		printf("%d",z);
	}
	else if(c=='-')
	{
	
		z=a-b;
		printf("%d",z);
	}
	else
	{
		printf("error");
	}
	return 0;
}

Measured memory_bytes: 256
al=list('abcdefghijklmnopqrstuvwxyz')
#####segfunc######                                                              
def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val                                                                    
    for i in range(n):
        seg[i+num-1]=1<<al.index(init_val[i])
    #built                                                                      
    for i in range(num-2,-1,-1):
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
    
def update(k,x):
    k+=num-1
    seg[k]=x
    while k+1:
        k=(k-1)//2
        seg[k]=segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p+=num-1
    q+=num-2
    res=ide_ele
    while q-p>1:
        if p&1==0:
            res=segfunc(res,seg[p])
        if q&1==1:
            res=segfunc(res,seg[q])
            q-=1
        p=p//2
        q=(q-1)//2
    if p==q:
        res=segfunc(res,seg[p])
    else:
        res=segfunc(segfunc(res,seg[p]),seg[q])
    ans=0
    while res>0:
        if res%2==1:
            ans+=1
        res=res//2
    return ans

ide_ele=0
n=int(input())
num=2**(n-1).bit_length()
seg=[ide_ele]*2*num
a=list(input())
init(a)
ans=0
q=int(input())

for i in range(q):
    p=list(map(str,input().split()))
    if p[0]=='1':
        update(int(p[1])-1,1<<al.index(p[2]))
    else:
        print(query(int(p[1])-1,int(p[2])))
#for i in range(n):
    #ans=max(gcd(query(0,i),query(i+1,n)),ans)
#print(ans)


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

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

    vector<int> V;
    V.push_back(1);
    for (int b = 2; b <= x; b++) {
        for (int p = 2; pow(b, p) <= x; p++) {
            V.push_back(pow(b, p));
        }
    }

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

    cout << V[V.size() - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
/*
  AOJ 2265
  Title:Programming Contest Challenge Book
  @kankichi573
*/
#include <stdio.h>
#define max(x,y) (((x)>(y))?(x):(y))

int N;
long long a[100000];

char table[9][6]={{0,1,3,2,4,5},
		  {0,1,4,2,3,5},
		  {0,1,5,2,3,4},
		  {0,2,3,1,4,5},
		  {0,2,4,1,3,5},
		  {0,2,5,1,3,4},
		  {0,3,4,1,2,5},
		  {0,3,5,1,2,4},
		  {0,4,5,1,2,3}};
		 
int is_triangle(long long a1,long long a2,long long a3)
{
  return (a1<a2+a3) && (a2<a3+a1) && (a3<a1+a2);
}


int compare_ll(const void *a, const void *b)
{
  if( *(long long *)a > *(long long *)b)
    return(-1);
  if( *(long long *)a < *(long long *)b)
    return(1);
  if( *(long long *)a == *(long long *)b)
    return(0);
}
long long solve(int start,int tri_no,int n,long long acc) 
{
#ifdef DEBUG
  printf("%d %d %d %lld|",start,tri_no,n,acc);
#endif
  if(tri_no==2)
    return(acc);
  if(n < (2-tri_no)*3)
    return(0);
  if(is_triangle(a[start],a[start+1],a[start+2]))
    return(solve(start+3,tri_no+1,n-3,acc+a[start]+a[start+1]+a[start+2]));
  else
    return(solve(start+1,tri_no,n-1,acc));
}
long long solve2()
{
  int i,j,k;
  long long ret;

  ret=0;
  for(i=0;i<N-6;i++)
    for(j=0;j<9;j++)
      {
	if(is_triangle(a[i+table[j][0]],
		       a[i+table[j][1]],
		       a[i+table[j][2]]) &&
	   is_triangle(a[i+table[j][3]],
		       a[i+table[j][4]],
		       a[i+table[j][5]]))
       
	  {
	    for(k=0;k<6;k++)
	      ret += a[i+k];
	    //printf("s2=%d\n",i);
	    return(ret);
	  }
      }
  return(0);
}
main()
{
  int i;
  long long ret,ret1;
  scanf("%d",&N);
  for(i=0;i<N;i++)  
    scanf("%lld",&a[i]);
  qsort(a,N,sizeof(long long),compare_ll);
#ifdef DEBUG
  for(i=0;i<N;i++)  
    printf(" %lld\n",a[i]);
  for(i=0;i<N-1;i++)
    printf("[%d] %lld\n",i,a[i]-a[i+1]-a[i+2]);
#endif
  
  ret=solve(0,0,N,0); // 3ren * 2
  ret1=solve2();      // 6ren
  printf("%lld\n",max(ret,ret1));
  return(0);
}

Measured memory_bytes: 1912
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        var input = Console.ReadLine().Split(' ');

        int A = TOI(input[0]);
        int B = TOI(input[1]);

        Console.WriteLine(A*B);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }
}

Measured memory_bytes: 27528
N=int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

import itertools

seq = list(range(1, N+1))
ptr = list(itertools.permutations(seq, N)) #順列列挙

#print(seq)
#print(ptr)

tmp1=ptr.index(P) #要素番号を格納する
tmp2=ptr.index(Q) #要素番号を格納する

print(abs(tmp1-tmp2))

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

using i64 = int64_t;

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for(int i=0;i<h;++i){
        cin >> grid[i];
    }

    deque<deque<bool>> visited(h, deque<bool>(w, false));
    i64 ans = 0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(visited[i][j])continue;
            if(grid[i][j] == '.')continue;
            queue<pair<int, int>> que;
            que.push({i, j});
            visited[i][j] = true;
            i64 black = 1, white = 0;
            while(!que.empty()){
                auto cur = que.front(); que.pop();
                for(int k=0;k<4;++k){
                    int ny = cur.first + dy[k], nx = cur.second + dx[k];
                    if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
                    if(visited[ny][nx])continue;
                    if(grid[ny][nx] == grid[cur.first][cur.second])continue;
                    //cout << ny << " " << nx << endl;
                    que.push({ny, nx});
                    visited[ny][nx] = true;
                    if(grid[ny][nx] == '#')black++;
                    else white++;
                }
            }
            //cout << black << " " << white << endl;
            ans += black * white;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
int main() {
	int n, k;
	while (scanf("%d%d",&n,&k)) {
		if (n==0&&k==0) break;
		vector<string> str(n);
		for (int i=0; i<n; i++) cin>>str[i];
		set<string> res;
		if (k==2) {
			for (int i=0; i<n; i++)
				for (int j=0; j<n; j++)
					if (i!=j) res.insert(str[i]+str[j]);
		}
		if (k==3) {
			for (int i=0; i<n; i++)
				for (int j=0; j<n; j++)
					for (int k=0; k<n; k++)
						if (i!=j&&i!=k&&j!=k) res.insert(str[i]+str[j]+str[k]);
		}
		if (k==4) {
			for (int i=0; i<n; i++)
				for (int j=0; j<n; j++)
					for (int k=0; k<n; k++)
						for (int l=0; l<n; l++)
							if (i!=j&&i!=k&&i!=l&&
								j!=k&&j!=l&&k!=l) res.insert(str[i]+str[j]+str[k]+str[l]);
		}
		printf("%d\n",res.size());
	}
}

Measured memory_bytes: 0
### main

while true
  n = gets.strip.to_i
  break if n == 0

  grid = []
  n.times.each do
    hl = gets.strip.split('').map{|s| s == "1"}
    grid << hl
  end

  max_c = 0

  # horizontal
  for y in (0...n)
    c = 0
    for x in (0...n)
      if grid[y][x]
        c += 1
        max_c = c if max_c < c
      else
        c = 0
      end
    end
  end

  # vertical
  for x in (0...n)
    c = 0
    for y in (0...n)
      if grid[y][x]
        c += 1
        max_c = c if max_c < c
      else
        c = 0
      end
    end
  end

  # diagonal (top-right -> bottom-left)
  nn = 2 * n - 2
  for d in (0..nn)
    c = 0
    x = 0
    y = d - x
    while x < n && y >= 0
      if y < n && grid[y][x]
        c += 1
        max_c = c if max_c < c
      else
        c = 0
      end

      x += 1
      y -= 1
    end
  end

  # diagonal (top-left -> bottom-right)
  for d in (-(n - 1)..(n - 1))
    c = 0
    x = 0
    y = x + d
    while x < n && y < n
      if y >= 0 && grid[y][x]
        c +=1
        max_c = c if max_c < c
      else
        c = 0
      end

      x += 1
      y += 1
    end
  end

  p max_c
end

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll temp = a[0];
    rep(i, n - 1){
        temp = __gcd(temp, a[i + 1]);
    }
    print(temp);
}

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

int main() {
	string S;
  	string T;
  	int a=0;
  
  	cin>> S >> T;
  
  	for(int i=0;i<S.size();i++){
     	if(S[i]!=T[i])  a=1;
    }
  
  	if(a) cout<<"No"<<endl;
  	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3624
x,y,A,B,C=map(int,input().split())
pa=list(map(int,input().split()))
qb=list(map(int,input().split()))
rc=list(map(int,input().split()))
pa.sort()
qb.sort()
temp=0

pa=pa[-x:]
qb=qb[-y:]
paa=pa+rc
paa.sort()
paa1=paa[-x:]
paa2=paa[:-x]
qbb=qb+paa2
qbb.sort()
qbb1=qbb[-y:]
print(sum(paa1)+sum(qbb1))

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

int n, p, s, m;

int main(){
	cin >> n;
	s = m = 0;
	for (int i = 0; i < n; ++i){
		cin >> p;
		s += p;
		if (m < p) m = p;
	}
	cout << (s - m/2);
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
//#define debug(x) cerr << #x << " : " << x << endl
#define debug(...)

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

vector< vector<long long> > get_Combination_array(int n){
    vector< vector<long long> > nCk;
    nCk.resize(n+1, vector<ll>(n + 1));
    nCk[0][0]=1;
    repeat(i, 1, n+1) {
        nCk[i][0]=nCk[i-1][0];
        repeat(j, 1, i + 1) {
            nCk[i][j]=nCk[i-1][j]+nCk[i-1][j-1];
        }
    }
    return nCk;
}


class Solver {
  public:
    bool solve() {
        int N, P; cin >> N >> P;
        int odd = 0, even = 0;
        rep(i, N) {
            int a; cin >> a;
            odd += a % 2;
            even += a % 2 == 0;
        }
        debug(odd); debug(even);
        auto nCk = get_Combination_array(N);
        debug(nCk);
        ll ans = 0;
        if(P == 1) {
            for(int i = 1; i <= odd ;i += 2) ans += nCk[odd][i];
            ans *= pow(2, even);
        } else {
            for(int i = 0; i <= odd ;i += 2) ans += nCk[odd][i];
            ans *= pow(2, even);
        }        
        cout << ans << endl;
        
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 512
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    from collections import Counter
    M = max(A) + 1
    B = [True] * (M+1)
    A = sorted(A)
    C = Counter(A)

    answer = 0
    for a in A:
        if B[a]:
            for j in range(a, M, a):
                B[j] = False
            if C[a] > 1:
                continue
            else:
                answer += 1

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()


Measured memory_bytes: 43396
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1005;
const char END = '\n';

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N, K, Q;
	cin >> N >> K >> Q;
	vector<ll> A(Q), Ans(N, K), sub(N, 0);
	rep(i, Q) {
		cin >> A[i];
		sub[A[i] - 1]++;
	}

	rep(i, N) {
		sub[i] = Q - sub[i];
		Ans[i] -= sub[i];
		if (Ans[i] > 0)
			cout << "Yes" << END;
		else
			cout << "No" << END;
	}
	return 0;
}


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

int main(){
    int a, b;
    scanf("%d%d", &a, &b);   
    for(int i=1;i<=1000000;i++){
        if(8*i/100 == a && 10*i/100 == b){
            printf("%d\n", i);
            return 0;
        }
    }
    printf("-1\n");
}

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

const int MAXN = 51;
const int H = 222;
const int W = 222;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
int n;
int l[MAXN], t[MAXN], r[MAXN], b[MAXN];
vector<int> xs, ys;
int G[H][W];

void dfs(int i, int j) {
  G[i][j] = 1;
  for(int k = 0; k < 4; ++k) {
    int ni = i + di[k];
    int nj = j + dj[k];
    if(ni < 0 || ni >= H) continue;
    if(nj < 0 || nj >= W) continue;
    if(G[ni][nj]) continue;
    dfs(ni, nj);
  }
}

int main() {
  while(cin >> n && n) {
    xs.clear();
    ys.clear();
    for(int i = 0; i < n; ++i) {
      cin >> l[i] >> t[i] >> r[i] >> b[i];
      xs.push_back(l[i]);
      xs.push_back(r[i]);
      ys.push_back(t[i]);
      ys.push_back(b[i]);
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    for(int i = 0; i < n; ++i) {
      l[i] = lower_bound(xs.begin(), xs.end(), l[i]) - xs.begin();
      r[i] = lower_bound(xs.begin(), xs.end(), r[i]) - xs.begin();
      t[i] = lower_bound(ys.begin(), ys.end(), t[i]) - ys.begin();
      b[i] = lower_bound(ys.begin(), ys.end(), b[i]) - ys.begin();
      l[i] = l[i] * 2 + 1;
      r[i] = r[i] * 2 + 1;
      t[i] = t[i] * 2 + 1;
      b[i] = b[i] * 2 + 1;
    }
    memset(G, 0, sizeof(G));
    for(int i = 0; i < n; ++i) {
      for(int x = l[i]; x <= r[i]; ++x) {
        G[t[i]][x] = G[b[i]][x] = 1;
      }
      for(int y = b[i]; y <= t[i]; ++y) {
        G[y][l[i]] = G[y][r[i]] = 1;
      }
    }
    int res = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(G[i][j]) continue;
        dfs(i, j);
        res += 1;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 2952
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double n = scan.nextInt();
        double k = scan.nextInt();
        int a = 0;
        int c = 0;
        double out = 0;
        for(int i = 1; i <= n; i++){
            a = i;
            while(a < k){
                a *= 2;
                c++;
            }
            out += (1 / n) * Math.pow(0.5, c);
            c = 0;
        }
        System.out.println(out);
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	ll n, m, i, j;
	cin >> n >> m;
	vector <string> s(n);
	for(i = 0; i < n; i++)
		cin >> s[i];
	vector <vll> dp(n);
	for(i = 0; i < n; i++)
		dp[i].resize(m, 0);
	dp[0][0] = 1;
	for(i = 0; i < n; i++)
		for(j = 0; j < m; j++)
			if(s[i][j] == '.')
			{
				if(i + 1 < n)
					if(s[i + 1][j] == '.')
						dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
				if(j + 1 < m)
					if(s[i][j + 1] == '.')
						dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
			}
	cout << dp[n - 1][m - 1] << endl;
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, c = 0, d, e;
	cin >> a >> b;
	for (int h = a; h <= b; h++) {
		if (h / 10000 == h % 10) {
			if (h / 1000 - h / 10000 * 10 == (h % 100 - h % 10) / 10) {
				c++;
			}
		}
	}
	cout << c << endl;
	cin >> e;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void)
{
    int k;
	vint a(5);
	for (int i = 0; i < 5; i++)cin >> a[i];
	cin>>k;
	sort(a.begin(), a.end());
	if (abs(a[0] - a[4]) <= k)cout << "Yay!" << endl;
	else cout << ":(" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  // ここでストリームに obj を書き込みます。
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

int ins(int n){
  int k=0;
  rep(i,n){
    int a; cin >>a; a--;
    k|=1<<a;
  }
  return k;
}

int main(){
  int n,m; cin >>n >>m; 
  vector<int> v(m),cost(m);

  rep(i,m){
    int b;
    cin >> cost[i] >> b;
    v[i]=ins(b);
  }
  map<int,int> mp;
  mp[0]=0;
  rep(i,m){
    map<int,int> tmp;
    for(pair<int,int> x:mp){
      auto itr=tmp.find(x.first|v[i]);
      if(itr==tmp.end())tmp[x.first|v[i]]=x.second+cost[i];
      else chmin(itr->second,x.second+cost[i]);
    }
    if(df) print("t:",tmp);
    for(pair<int,int> x:tmp){
      auto itr=mp.find(x.first);
      if(itr==mp.end()) mp[x.first]=x.second;
      else chmin(itr->second,x.second);
    }
    if(df) print("m:",mp);
  }
  auto itr=mp.find((1<<n)-1);
  print(itr==mp.end()?-1:itr->second);
}


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}
#define NCR 
const int NC=600005,MOD=M;
ll inv[NC],fac_inv[NC],fac[NC];
void initialize()
{
    ll i;
    inv[1]=1;
    for(i=2;i<=NC-2;i++)
        inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD; 
    fac[0]=fac[1]=1;
    for(i=2;i<=NC-2;i++)
        fac[i]=i*fac[i-1]%MOD;
    fac_inv[0]=fac_inv[1]=1;
    for(i=2;i<=NC-2;i++)
        fac_inv[i]=inv[i]*fac_inv[i-1]%MOD;
}
ll ncr(ll n,ll r)
{
    if(n<r) return 0;
    return (fac[n]*fac_inv[r]%MOD)*fac_inv[n-r]%MOD;
}

int _runtimeTerror_()
{
    ll n,m;
    cin>>n>>m;
    ll ans=power(ncr(m,n)*fac[n]%MOD,2,MOD);
    for(int i=1;i<=n;++i)
    {
        ll x=ncr(n,i)*ncr(m,i)%MOD*fac[i]%MOD;
        x=x*power(ncr(m-i,n-i)*fac[n-i]%MOD,2,MOD)%MOD;
        if(i&1)
            ans-=x;
        else
            ans+=x;
        ans=(ans%MOD+MOD)%MOD;
    }
    cout<<ans;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 17704
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int dfs(int cur, vvi& graph, vi& visit) {
    visit[cur] = 1;
    for (int nxt : graph[cur]) {
        if (visit[nxt]) continue;
        visit[cur] += dfs(nxt, graph, visit);
    }
    return visit[cur];
}

void dfs2(int cur, vvi& graph, vi& visit, vi& sub) {
    visit[cur] = 1;
    for (int nxt : graph[cur]) {
        if (visit[nxt]) continue;
        if (sub[nxt] > (graph.size()-1)/2) visit[cur] = -1;
        if (sub[nxt] >= (graph.size()-1)/2) dfs2(nxt, graph, visit, sub);
    }
}

int mod = 1e9 + 7;

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

    vll memo(2005);
    for (int i = 3; i <= 2000; i++) {
        memo[i] = 1;
        for (int j = i-3; j >= 0; j--) memo[i] = (memo[i] + memo[j]) % mod;
    }

    int N; cin >> N;
    cout << memo[N];
    
}

Measured memory_bytes: 3668
import numpy as np
bingo = np.ndarray((3,3)).astype(np.int)
for i in range(3):
    line = list(map(int,input().split()))
    bingo[i] = line
N = int(input())

for _ in range(N):
    b = int(input())
    bingo[bingo==b] = 0

row = min(np.max(bingo,axis=1))
col = min(np.max(bingo,axis=0))
diag = min(bingo[0,0]+bingo[1,1]+bingo[2,2],bingo[0,-1]+bingo[1,-2]+bingo[2,-3])
if min(row,col,diag)==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12668
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  long long N;
  cin >> N;

  vector<long long> A(N),B(N);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i) >> B.at(i);
  }

  long long ans = 0;
  for(int i = N-1;i >= 0;i--) {
    if((A.at(i)+ans) % B.at(i) == 0) continue;
    ans += B.at(i) - ((A.at(i)+ans) % B.at(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792