akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main(){
  int d,t,s;
  cin >>d >> t >> s;
  long x = s*t;
  if(x>=d){
    cout << "Yes" <<endl;
    
  }else{
    cout << "No" <<endl; 
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/24  Problem: ABC 122 C / Link: http://abc122.contest.atcoder.jp/tasks/abc122_c  ----- */

struct Cumusum {
	vector<LL>csum;
	Cumusum(vector<LL>&a) {
		csum.assign((int)a.size() + 1, 0);
		for (int i = 0; i < (int)a.size(); i++) {
			csum[i + 1] = csum[i] + a[i];
		}
	}
	LL query(int l, int r) {
		return csum[r] - csum[l];
	}
};

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

	LL N, Q; cin >> N >> Q;
	string s; cin >> s;
	VL a(N);
	FOR(i, 0, N - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			a[i]++;
		}
	}
	DD(De(s,a))
		Cumusum csum(a);
	FOR(_, 0, Q) {
		LL L, R; cin >> L >> R;
		L--, R--;
		LL res = csum.query(L, R + 1);
		if (R != N - 1) {
			if (s[R] == 'A'&&s[R + 1] == 'C')res--;
		}
		cout << res << endl;
	}


	return 0;
}


Measured memory_bytes: 2640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	if(N<1000){
		cout<<"ABC";
	}
	else{
		cout<<"ABD";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll uni[100005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    int n,m,k;
    cin>>n>>m>>k;
    int a,b;
    vector<set<int> > v(n);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        v[a].insert(b);
        v[b].insert(a);
        connect(a,b);
    }
    int ans[n];
    for(int i=0;i<n;i++)ans[i]=size(i)-v[i].size()-1;
    for(int i=0;i<k;i++){
        cin>>a>>b;
        a--;b--;
        if(root(a)==root(b)){
            ans[a]--;
            ans[b]--;
        }
    }
    for(int i=0;i<n;i++)cout << ans[i]<<" ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 16896
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main(int argc, const char * argv[]) {

    ll N; cin >> N;
    vector<ll> L(N);
    for(ll i=0;i<N;i++){
        cin >> L[i];
    }
    
    ll ans=0;
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<N;j++){
            for(ll k=j+1;k<N;k++){
                if(L[i]==L[j] || L[i]==L[k] ||L[j]==L[k] )
                    continue;
                if(L[i]<L[j]+L[k] &&L[j]<L[i]+L[k]&&L[k]<L[i]+L[j]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;

}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    map<lli, int> m;
    for (int i = 0; i < n; ++i) {
      lli a;
      cin >> a;
      ++m[a];
    }
    vector<lli> v;
    lli mx = 0;
    each (i, m) {
      if (2 <= i.second) v.push_back(i.first);
      if (4 <= i.second) mx = max(mx, i.first * i.first);
    }
    if (2 <= v.size()) {
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      mx = max(mx, v[0] * v[1]);
    }
    cout << mx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

char S[100];

int main()
{
  int cnt;
  int N;
  int i;
  int r = 0;
  int b = 0;

  cnt = scanf("%d", &N);
  cnt = scanf("%s", S);

  for (i=0; i<N; i++) {
    if(S[i] == 'B') {
      b++;
    } else {
      r++;
    }
  }

  if (r > b) {
    printf ("Yes");
  } else {
    printf ("No");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 100005;
const ld pi = 3.141592653;
const ll MOD = 1000000007;

using namespace std;

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

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1, cac=0, cwa=0, ctle=0, cre=0;
        cin>>T;
        while(T--)
        {
                string s;
                cin>>s;
                if(s[0]=='A') cac++;
                else if(s[0]=='W') cwa++;
                else if(s[0]=='T') ctle++;
                else cre++; 
        }
        cout<<"AC x "<<cac<<"\n";
        cout<<"WA x "<<cwa<<"\n";
        cout<<"TLE x "<<ctle<<"\n";
        cout<<"RE x "<<cre<<"\n";
        return 0;
}


Measured memory_bytes: 3528
from collections import deque
S = deque(input())
Q = int(input())
Qr = [list(input().split()) for i in range(Q)]
isForward = True
for i in range(Q):
    if Qr[i][0] == "1":
        isForward = not(isForward)
    elif (isForward and  Qr[i][1] == "1") or (not(isForward) and Qr[i][1] == "2"):
        S.appendleft(Qr[i][2])
    else:
        S.append(Qr[i][2])
S = list(S)
if not(isForward):
    S.reverse()
print("".join(S))

Measured memory_bytes: 35316
n, w = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(n)]


dp = [[0 for i in range(w + 1)] for _ in range(n + 1)]
for j in range(w + 1):
    dp[0][j] = 0


# update
for i in range(1, n + 1):
    for j in range(w + 1):
        if j - item[i - 1][1] >= 0:
            dp[i][j] = max(dp[i - 1][j - item[i - 1][1]] + item[i - 1][0], dp[i - 1][j])
            pass
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][w])


Measured memory_bytes: 42468
#include<iostream>
using namespace std;
int main(){
    int a;
    cin>>a;
    if(a==25) cout<<"Christmas"<<endl;
    else if(a==24) cout<<"Christmas Eve"<<endl;
    else if(a==23) cout<<"Christmas Eve Eve"<<endl;
    else if(a==22) cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, V = mapint()
B, W = mapint()
T = int(input())
if abs(B-A)<=T*(V-W):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9176
def maxV(R, n):
    minv = R[0]
    maxv = R[1] - R[0]
    for i in range(1, n):
        maxv = max(maxv, R[i]-minv)
        minv = min(minv, R[i])
    return maxv

n = int(input())
R = [int(input()) for i in range(n)]
print(maxV(R, n))



Measured memory_bytes: 13596
a,b,m=map(int,input().split())
ali= list(map(int,input().split()))	
bli= list(map(int,input().split()))	
min=min(ali)+min(bli)
for i in range(0,m):
  x,y,c=map(int,input().split())
  mon=ali[x-1]+bli[y-1]-c
  if mon<min:
    min=mon
    
print(min)

Measured memory_bytes: 18736
N,K = map(int,input().split())
s = [input() for i in range(K*2)]
l = []
c = 0
k = 0
m = 0
f = []
# スペース区切りの整数の入力
num = []
for i in range(K*2):
  if i%2==1:
    for m in range(int(s[i-1])):
      num.append(s[i].split()[m])
for j in range(1,N+1):
  f.append(num.count(str(j)))
print(f.count(0))

Measured memory_bytes: 9360
#include <iostream>
#include <vector>

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

    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<int> ans(n, -1);
    int l = 0, r = n - 1, idx = n - 1;
    while (l <= r) {
        ans[l++] = a[idx--];

        if (l <= r) ans[r--] = a[idx--];
    }

    for (int i = 0; i < n; i++) {
        std::cout << ans[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
int main(){
  char S[11];
  scanf("%s",S);
  int i;
  int cnt=0;
  int ans=0;
  for(i=0;S[i]!='\0';i++){
	if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G') {
      cnt++;
    }
    else{
      if(cnt>ans) ans=cnt;
      cnt=0;
    }
    
  }
  
  if(cnt>ans) ans=cnt;
  
  printf("%d",ans);
  return 0;
}
    
    

Measured memory_bytes: 128
def resolve():
    import sys
    input = sys.stdin.readline

    import heapq
    def dijkstra_heap(s,g,edge):
        #始点sから各頂点への最短距離
        d = [10**20] * (n+2)
        used = [True] * (n+2) #True:未確定
        d[s] = 0
        used[s] = False
        edgelist = []
        sx,sy,sr=edge[s][0],edge[s][1],edge[s][2]
        for i in range(n+2):
            x,y,r=edge[i][0],edge[i][1],edge[i][2]
            dist=((x-sx)**2+(y-sy)**2)**(1/2)
            heapq.heappush(edgelist,(max(dist-r-sr,0),i))
        while len(edgelist):
            minedge = heapq.heappop(edgelist)
            #まだ使われてない頂点の中から最小の距離のものを探す
            v = minedge[1]
            if not used[v]:
                continue
            d[v] = minedge[0]
            used[v] = False
            bx,by,br=edge[v][0],edge[v][1],edge[v][2]
            for i in range(n+2):
                x,y,r=edge[i][0],edge[i][1],edge[i][2]
                dist=((x-bx)**2+(y-by)**2)**(1/2)
                if used[i]:
                    heapq.heappush(edgelist,(max(dist-r-br,0)+d[v],i))
            if not used[g]:
                break
        return d[g]

    sx,sy,gx,gy = map(int,input().split()) #n:頂点数　w:辺の数
    n=int(input())
    edge=[(sx,sy,0),(gx,gy,0)]
    for i in range(2,n+2):
        x,y,r=map(int,input().split())
        edge.append((x,y,r))
    print(dijkstra_heap(0,1,edge))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 117340
#include<bits/stdc++.h>
#define ll long long
#define M 1000000007

using namespace std;

// Solve function here


// End Solve function

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    //ifstream cin("input.in");
	//clock_t start, finish;
	int n, m; cin >> n >> m;
	if(m >= n) cout << "unsafe\n";
	else cout << "safe\n";
	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;

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


int main(){
  int n;
  cin >> n;
  if(n <= 999)  cout << "ABC" << endl;
  else cout << "ABD" << endl;


}


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

const int N = 2e3 + 10, mod = 1e9 + 7;

pair<int, int> arr[N];
long long dp[N][N];
int n;

long long solve(int i, int l) {
    if(!arr[i].first) return 0;
    if(dp[i][l] != -1) return dp[i][l];
    int r = n - (i - l);
    long long ret = solve(i + 1, l + 1) + 1ll * arr[i].first * abs(arr[i].second - l);
    ret = max(ret, solve(i + 1, l) + 1ll * arr[i].first * abs(arr[i].second - r));
    return dp[i][l] = ret;
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) {
            scanf("%d", &arr[i].first);
            arr[i].second = i;
        }
        sort(arr + 1, arr + n + 1, greater<pair<int, int>>());
        //for(int i = 1; i <= n; i++) cout << arr[i].first << ' ' << arr[i].second << '\n';
        memset(dp, -1, sizeof(dp));
        cout << solve(1, 1);
        // for(int i = 0; i < n; i++) {
        //     for(int l = 1; l < n; l++) {
        //         if(l - 1 > i) break;
        //         int r = n - (i - l);
        //         dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + 1ll * abs(arr[i + 1].second - l) * arr[i + 1].first);
        //         dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + 1ll * abs(arr[i + 1].second - r) * arr[i + 1].first);
        //     }
        // }
        // cout << dp[1][2] << ' ' << dp[2][2] << ' ' << dp[3][3] << ' ' << dp[4][4] << '\n';
        // long long ans = 0;
        // for(int l = 1; l <= n; l++) ans = max(ans, dp[n][l]);
        // printf("%lld\n", ans);
    }    
    return 0;
}

Measured memory_bytes: 35356
<?php
$N = trim(fgets(STDIN));
//list($K,$X) =  explode(" ",trim(fgets(STDIN)));
$P =  explode(" ",trim(fgets(STDIN)));
$Q =  explode(" ",trim(fgets(STDIN)));

$pstr = implode($P,",");
$qstr = implode($Q,",");

$a = range(1,$N);
$vv = (pc_permute($a));
foreach($vv as $v) {
  $str[]=implode($v,",");
}
sort($str);
$ppos=0;
$qpos=0;
foreach($str as $k=>$s) {
  if ($s == $pstr) $ppos =$k;
  if ($s == $qstr) $qpos =$k;
}
printf("%d\n",abs($qpos-$ppos));

//https://stackoverflow.com/questions/5506888/permutations-all-possible-sets-of-numbers
function pc_permute($items, $perms = array( )) {
    if (empty($items)) {
        $return = array($perms);
    }  else {
        $return = array();
        for ($i = count($items) - 1; $i >= 0; --$i) {
             $newitems = $items;
             $newperms = $perms;
         list($foo) = array_splice($newitems, $i, 1);
             array_unshift($newperms, $foo);
             $return = array_merge($return, pc_permute($newitems, $newperms));
         }
    }
    return $return;
}


Measured memory_bytes: 25464
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for(int i = 0; i < N; i++) h[i] = sc.nextInt();
		int ans = 0;
		for(int interval = N; interval >= 1; interval--) {
			for(int i = 0; i + interval - 1 < N; i++) {
				int j = i + interval - 1;
				int min = Integer.MAX_VALUE;
				for(int k = i; k<=j; k++) min = Math.min(min, h[k]);
				if(min == 0) continue;
				for(int k = i; k<=j; k++) {
					h[k] -= min;
				}
				ans += min;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int S, W;
    cin >> S >> W;
    if (S <= W)
        cout << "unsafe\n";
    else
        cout << "safe\n";

    return 0;
}


Measured memory_bytes: 3636
import sys

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors  + upper_divisors[::-1]


input = sys.stdin.readline

n = int(input())

yaku_list = make_divisors(n)
length = len(yaku_list)
half_index = int(length/2)

a = 0
b = 0
if length % 2 == 0:
    a = yaku_list[half_index]
    b = yaku_list[half_index-1]
else:
    a = yaku_list[half_index]
    b = a

keta_a = len(str(a))
keta_b = len(str(b))

print(max(keta_a,keta_b))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    vector<int> L(2*N);
    REP(i, 2*N) cin >> L[i];
    
    llint ans = 0;
    sort(All(L));
    REP(i, 2*N){
        ans += L[i++];
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1005000000
#define MOD 1000000007
#define N 200005
#define M 1000005
#define LOG 19
#define KOK 32000
#define EPS 0.000000001
using namespace std;

int n,x,y,ans,v;
int s[N*4],dp[N],pre[N];
vector<ii> ar;

int get(int node,int bas,int son,int x,int y) {

	if(bas>=x && son<=y) return s[node];

	if(bas>y || son<x) return inf;

	return min(get(node<<1,bas,orta,x,y),get(node<<1|1,orta+1,son,x,y));

}

void up(int node,int bas,int son,int x,int val) {

	if(bas>x || son<x) return ;

	if(bas==x && son==x) {

		umin(s[node],val);

		return;

	}

	up(node<<1,bas,orta,x,val);
	up(node<<1|1,orta+1,son,x,val);

	s[node]=min(s[node<<1],s[node<<1|1]);

}

void build(int node,int bas,int son,int val) {

	if(bas==son) {

		s[node]=val;

		return ;

	}

	build(node<<1,bas,orta,val);
	build(node<<1|1,orta+1,son,val);

	s[node]=min(s[node<<1],s[node<<1|1]);

}

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d",&n);

	vector<ii> range(n+1);

	for(int i=1;i<=n;i++) {

		scanf("%d %d",&x,&v);

		ar.pb({x,v});

	}

	sort(all(ar));

	int cnt=0;

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

		++cnt;

		while(i+1<n && ar[i].st==ar[i+1].st) {

			swap(ar[i].st,ar[i].nd);

			ar[i].nd=cnt;

			i++;

		}
		
		swap(ar[i].st,ar[i].nd);

		ar[i].nd=cnt;

	}

	sort(all(ar));

	build(1,1,cnt,inf);

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

		up(1,1,n,ar[i].nd,i+1);

		range[i+1].st=get(1,1,cnt,ar[i].nd,cnt);

	}

	build(1,1,cnt,inf);

	for(int i=n-1;i>=0;i--) {

		up(1,1,n,ar[i].nd,-i-1);

		range[i+1].nd=-get(1,1,cnt,1,ar[i].nd);

	}

	range[0]={-inf,0};

	sort(all(range),[](ii a,ii b) {

		if(a.nd==b.nd) return a.st<b.st;

		return a.nd<b.nd;

	});

	dp[0]=pre[0]=1;

	for(int i=1;i<=n;i++) {

		int bas=0,son=i-1;

		while(bas<=son) {

			if(range[orta].nd<range[i].st-1) bas=orta+1;
			else son=orta-1;

		}

		dp[i]=(pre[i-1]-(son<0?0:pre[son])+MOD)%MOD;

		pre[i]=(pre[i-1]+dp[i])%MOD;

	}

	for(int i=n;i>=1;i--) {

		if(range[i].nd<n) break ;

		ans=(ans+dp[i])%MOD;

	}

	printf("%d",ans);

}



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

int main() {
  int R = 0;
  int G = 0;
  
  cin >> R >> G;
  if ((R>=0) && (R<=4500) && (G>=0) &&(G<=4500)){
    cout << 2*G - R << endl;
  } else {
    cout << "0以上4500以下の整数を入力してください" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,i,j;
  cin>>n;
  long long int a[n][3],dp[n][3];
  for(i=0;i<n;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    if(!i){
      dp[i][0]=a[i][0];
      dp[i][1]=a[i][1];
      dp[i][2]=a[i][2];
    }
  }
  for(i=1;i<n;i++){
	dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
	dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
	dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
  }
  cout<<max(dp[n-1][2],max(dp[n-1][0],dp[n-1][1]));
}

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

#define int long long int
#define ull unsigned long long int
#define M (int)(1e9+7)
#define for0(i, n) for (int i = 0; i < (int)(n); i++) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); i++) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; i--) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; i--) // reverse 1 based


#define pb push_back
#define fi first
#define se second


#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef double ld;

//-------------------------------------------------------------------------------END----------------------------------------------------------------------------------//
int mod(int x){
    return ((x%M + M)%M);
}

int add(int a,int b){
    return mod(mod(a)+mod(b));
}

int mins(int a,int b){
    return mod(mod(a)-mod(b));
}

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

int modpower(int x, unsigned int y)  {  
    if(y==0)return 1;
    if(y==1)return x%M;

    int res=1;
    while(y){
        if(y%2==1)res=mul(res,x);
        x = mul(x,x);
        y = y/2;
    } 
    return res;
}


bool inc(vi vec){
    for1(i,vec.size()-1){
        if(vec[i]<vec[i-1])return 0;
    }
    return 1;
}


void solve(){
    int n;cin>>n;
    
    if(n==1){cout<<0<<'\n';return;}

    if(n==2){cout<<2<<'\n';return;}

    int ans=0;
    
    ans = mins(add(modpower(10,n),modpower(8,n)),mul(2,modpower(9,n)));

    cout<<ans;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout << fixed;
    //int tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}

Measured memory_bytes: 3648
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>

int main()
{
	int N;
	std::cin >> N;
	std::vector<std::uint64_t> val(3 * N);
	for (auto& v : val)
	{
		std::cin >> v;
	}
	std::uint64_t ret{};
	std::partial_sort(val.begin(), val.begin() + 2 * N, val.end(), std::greater<>());
	for (int i{}; i < N; ++i)
	{
		ret += val[2 * i + 1];
	}
	std::cout << ret << std::endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t n;
    cin >> n;

    if (n % 2 != 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int64_t twos = 0, fives = 0;

    for (int64_t p2 = 2; p2 <= n; p2 *= 2)
    {
        twos += n / p2;
    }
    for (int64_t p5 = 2 * 5; p5 <= n; p5 *= 5)
    {
        fives += n / p5;
    }

    cout << min(twos, fives) << endl;

    return 0;
}

Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    if (a + b) % 2 == 0 {
        p((a + b) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}

Measured memory_bytes: 4352
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  x: usize,
  y: usize,
  z: usize,
  k: usize,
  a: [u64; x],
  b: [u64; y],
  c: [u64; z],
  }

  let mut vec_xy = vec![];

  for i in 0..x {
    for j in 0..y {
      vec_xy.push(a[i] + b[j]);
    }
  }

  vec_xy.sort_by_key(|&x| Reverse(x));

  let mut vec_xyz = vec![];


  let z_end = min!(k, z);
  let i_end = min!(k, vec_xy.len());

  for i in 0..i_end {
    for j in 0..z_end {
      vec_xyz.push(vec_xy[i] + c[j]);
    }
  }

  vec_xyz.sort_by_key(|&x| Reverse(x));

  for i in 0..k {
    println!("{}", vec_xyz[i]);
  }

}


Measured memory_bytes: 45632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
ll a[N],b[N],suf[N];
int main(){
    int n; scanf("%d",&n);
    for(int i=0;i<=n;i++) scanf("%lld",&a[i]);
    if(n==0){
        if(a[0]==1) return 0 * printf("1\n");
        return 0 * printf("-1\n");
    }
    if(a[0]==1) return 0 * printf("-1\n");
    suf[n] = a[n];
    for(int i=n-1;i>=0;i--) suf[i] = suf[i+1] + a[i];
    b[0] = 1;
    for(int i=1;i<=n;i++) b[i] = min(suf[i],(b[i-1]-a[i-1])*2);
    for(int i=0;i<=n;i++) if(b[i]<a[i]) return 0 * printf("-1\n");
    ll ans = 0;
    for(int i=0;i<=n;i++) ans += b[i];
//    for(int i=0;i<=n;i++) cout<<b[i]<<' '; cout<<endl;
    printf("%lld\n",ans);
}


Measured memory_bytes: 6152
#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;

  //3と5で割り切れない数の総和を求める
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i%3 == 0) continue;
    if (i%5 == 0) continue;
    ans += i;
  }

  cout << ans << endl;

}


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

int main() {
    int n;
    int x[101], y[101], h[101];

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            bool flag = true;
            int ans = 0;
            int max = INT32_MAX;
            for (int i = 0; i < n; i++) {
                int tmp = abs(x[i] - cx) + abs(y[i] - cy);
                if (h[i] == 0) {
                    max = min(max, tmp);
                } else {
                    if (ans == 0) {
                        ans = tmp + h[i];
                    } else if (ans != tmp + h[i]) {
                        flag = false;
                        break;
                    }
                }
                if (ans > max) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << cx << " " << cy << " " << ans << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
n=int(input())
m=10**9+7
s=bin(n)[2:]
t=[[0,0,0]for i in range(len(s)+1)]
t[0][0]=1
for i in range(1,len(s)+1):
    if s[i-1]=="0":
        t[i][0]=t[i-1][0]+t[i-1][1]
        t[i][1]=t[i-1][1]
        t[i][2]=t[i-1][1]+t[i-1][2]*3
    else:
        t[i][0]=t[i-1][0]
        t[i][1]=t[i-1][0]+t[i-1][1]
        t[i][2]=t[i-1][2]*3+t[i-1][1]*2
    for j in range(3):
        t[i][j]%=m
print(sum(t[-1])%m)

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

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


Measured memory_bytes: 256
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) /@ (fun _ -> (cnv % read_line) ())

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let n = scan "%d" identity
let s = scan_listn n identity

module SMap = Map.Make (struct
    type t = string
    let compare = String.IString.compare
  end)

let () =
  let map = fold (fun m k -> SMap.modify_opt k
                     (function
                       | None -> Some 0
                       | Some n -> Some (n + 1)) m) SMap.empty s in
  let m = SMap.fold (fun _ v m -> if v > m then v else m) map 0 in
  SMap.filter (fun _ n -> n = m) map
  |> SMap.keys
  |> List.of_enum
  |> List.sort String.compare
  |> String.concat "\n"
  |> printf "%s\n"


Measured memory_bytes: 35904
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  double t, a;
  cin >> t >> a;
  vector<double> H(n);
  rep(i, n) cin >> H[i];
  int idx = 0;
  auto d = [&](int i) {
    return fabs(t - H[i] * 0.006 - a);
  };
  double mind = d(0);
  rep(i, n) {
    if(mind > d(i)) {
      mind = d(i);
      idx = i;
    }
  }
  cout << ++idx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  rep(i, n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  int ans = 0;
  rep(i, k) {
    ans += vec[i];
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
public class Main
{
    
    public static long low = 1, high = (long)Math.pow(3, 32), n;
    
    public static void main(String[] args)
    {
        n = new java.util.Scanner(System.in).nextLong();
        long ans = (n == 0) ? -1 : dfs(1, 1);
        System.out.println(ans + 1);
    }
    
    public static long dfs(long pos, long pace)
    {
        if(pos > n) return 0;
        // 3.0X
        if(pace < high)
        {
            long npace = 3 * pace;
            long npos = pos + npace;
            if(npos == n & (npace == 1 | npace == 3)) return 1;
            else
            {
//                if(npos > n) return 0;
                long temp = dfs(npos, npace);
                if (temp != 0) return 1 + temp;
            }
        }
        
        // 1.0X
        {
            long npace = pace;
            long npos = npace + pos;
            if(npos == n & (npace == 1 | npace == 3)) return 1;
            else
            {
//                if(npos > n) return 0;
                long temp = dfs(npos, npace);
                if (temp != 0) return 1 + temp;
            }
        }
        
        // 0.3X
        if(pace > low)
        {
            long npace = pace / 3;
            long npos = pos + npace;
            if(npos == n & (npace == 3 | npace == 1)) return 1;
            else
            {
//                if(npos > n) return 0;
                long temp = dfs(npos, npace);
                if(temp != 0) return 1 + temp;
            }
        }
        return 0;
    }
    
}


Measured memory_bytes: 26324
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    for (ll i = 0; i < N; i++) {
        cin >> L[i];
    }
    ll sum = accumulate(L.begin(), L.end(), (ll)0);
    ll max = *max_element(L.begin(), L.end());
    cout << (max < (sum - max) ? "Yes" : "No") << endl;
}

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

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

#define PB push_back
#define MP make_pair
#define IN insert
#define F first
#define S second

#define repa(i,fr,to,inc) for(int i = fr ; i <= to ; i += inc)
#define repb(i,fr,to,dec) for(int i = fr ; i >= to ; i -= dec)

clock_t present = clock();
void complexiti(){present = clock() - present;cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';}
ll nax = 1000000LL * 1000000LL * 1000000LL;


void solver(){
	//~ type your code here
	int n;
	cin >> n;
	vi v(n);
	for(auto &i:v)cin >> i;
	int ans = 0 , cnt = 0;
	repa(i,1,n-1,1){
		if(v[i] <= v[i-1])cnt++;
		else{
			cnt = 0;
		}
		ans = max(cnt , ans);
	}
	cout << ans << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


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

#define LL long long
#define ULL unsigned long long int
LL INF=1000000000000000001;
#define mx 100009
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define READ 	freopen("in.txt","r",stdin)
#define WRITE  	freopen("out.txt","w",stdout)
#define BOOST	ios_base::sync_with_stdio(false)


#define sf 	scanf
#define pf 	printf
#define F  	first
#define S  	second
#define pb 	push_back
#define NL	pf("\n")
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v)		sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(i=0;i<n;i++)
#define loop(i,s,n) for(i=s;i<n;i++)
#define rev(i,s,n)	for(i=n;i>=s;i--)
// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// comparison function for sort
//bool cmp( LL a,LL b ){
//	return a>b;
//}


// ------------------------------------------------------------
// POWER SET WITH BITMASK
//void powerSet(char *st, int set_size){
//
//    unsigned int pow_set_size = pow(2, set_size);
//    int counter, j,i;
//	vector<char> xxx;
//	for(counter = 0; counter < pow_set_size; counter++){
//		xxx.clear();
//		for(j = 0; j < set_size; j++){
//			if(counter & (1<<j))
//				xxx.pb( st[j] );
////				cout<<st[j];
//		}
//      NL;
//	}
//}



// ------------------------------------------------------------
// Big Mod
//#define mod 1000007
//LL bigMOd( LL a,LL p ){
//
//    if( p==0 )return 1%mod;
//    LL x = bigMOd( a,p/2 );
//    x = ((x%mod)*(x%mod))%mod;
//    if( p%2 ){
//        x = ((x%mod)*(a%mod))%mod;
//    }
//    return x;
//}

LL n,m;


int main(){

//	READ;WRITE;
//	BOOST;
    LL i,j,k,t,cs=0,q,r,c,x,d,u,v,a,b;
    LL w;

    cin>>w>>a>>b;

    if( b>a ){
        x = (b-a-w);
        if( x<0 )x=0;
        cout<<x<<endl;
    }
    else{
        x = (a-b-w);
        if( x<0 )x=0;
        cout<<x<<endl;
    }

//    main();
//    ch;
//    sl(t);
//    while(t--){
//        sl(n);
////        ch;
//    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>

using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		int m = i;
		double t = 1.0;
		while (m < k) {
			m *= 2;
			t /= 2;
		}
		ans += t;
	}
	cout << setprecision(10) << (double)ans/n << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    a = take_mod(a);
    b = take_mod(b);
    if (b == 0) return 0;
    ll res = mul(add(a, a), b >> 1);
    if(b & 1) res = add(res, a);
    return res;
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}


ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int main() {
    ll H, W;
    ll A, B;
    cin >> H >> W;
    cin >> A >> B;

    make_fact(200100);
    make_invfact(200100);

    ll res = 0;
    for(int i = 0; i < H-A; i++){
        ll x = comb(i+B-1, B-1);
        ll y = comb(H-i+W-B-2, H-i-1);
        res = add(res, mul(x, y));
    }


    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3328
n, m = gets.split.map(&:to_i)
from_1_to_any = []
from_any_to_n = []
m.times do
  a, b = gets.split.map(&:to_i)
  if a == 1 || b == 1
    from_1_to_any << ([a, b] - [1])[0]
  elsif a == n || b == n
    from_any_to_n << ([a, b] - [n])[0]
  end
end
# p from_1_to_any
# p from_any_to_n
# p from_1_to_any & from_any_to_n
# p (from_1_to_any & from_any_to_n).empty?
puts (from_1_to_any & from_any_to_n).empty? ? "IMPOSSIBLE" : "POSSIBLE"


Measured memory_bytes: 9864
import java.util.Scanner;

public class Main {

	static int n,w,h,s,t;
	static int[][] persimmon;
	static int[][] field,row;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			n=cin.nextInt();
			if(n==0){
				break;
			}
			w=cin.nextInt();
			h=cin.nextInt();
			persimmon=new int[n][2];
			field=new int[h+1][w+1];
			row=new int[h+1][w+1];
			for(int i =0;i<n;i++){
				int x=cin.nextInt();
				int y=cin.nextInt();
				field[y][x]=1;
			}
			s=cin.nextInt();
			t=cin.nextInt();

			for(int i = 1;i<=h;i++){
				for(int j = 1;j<=w;j++){
					row[i][j]=field[i][j]+row[i][j-1];
				}
			}
			for(int i = 1;i<=h;i++){
				for(int j = 1;j<=w;j++){
					//System.out.print(row[i][j]+" ");
				}
				//System.out.println();
			}
			int max=0;
			for(int i = 1;i+t<=h+1;i++){
				for(int j = 1;j+s<=w+1;j++){
					//System.out.println(i+" " +j+" " + row[i][j]);
					int sum=0;
					for(int k = 0;k<t;k++){
						sum+=row[i+k][j+s-1]-row[i+k][j-1];
					}
					max=Math.max(max,sum);
				}
			}
			System.out.println(max);
			
		}
	}

}

Measured memory_bytes: 13000
l = list(input())

num0 = 0
for i in range(0,len(l)):
    if l[i] == "0":
        num0 = num0 + 1

num1 = len(l) - num0

if num1 > num0:
    print(2*num0)
else:
    print(2*num1)
        

Measured memory_bytes: 3956
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n, k;
  cin >> n >> k;
  int ans = 0, x;
  rep(i, n){
    cin >> x;
    ans += min(x, abs(k, x)) * 2;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, D;
  vl A;
  cin >> N >> D;
  cout << ceil((long double)N / ((2 * D) + 1)) << endl;
  return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n, k, q;
  cin >> n >> k >> q;
  
  vi a(q);
  rep(i, 0, q){
    cin >> a[i];
    a[i]--;
  }

  vi p(n, k-q);
  rep(i, 0, q){
    p[a[i]]++;
  }

  rep(i, 0, n){
    if(p[i] <= 0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }

  return 0;
}


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

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

	int n;
	cin >> n;
	
	int ile = 0;
	
	for(int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		
		if(a == b)
		{
			ile++;
		}
		
		else
		{
			ile = 0;
		}
		
		if(ile == 3)
		{
			cout << "Yes\n";
			return 0;
		}
	}
	
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3608