akhauriyash/Code-Regression huggingface dataset:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
C = input()
flag = False
cnt = 0
for i in range(n):
    if not flag and C[i] == 'W':
        flag = True
    if flag:
        if C[i] == 'R':
            cnt += 1
        # elif C[i] == 'W':
        #     if i + 1 < n:
        #         if C[i+1] == 'W':
        #             pass
        #         else:
        #             cnt = max(cnt-1,0)
        #     else:
        #         cnt = max(cnt-1,0)
r = C.count('R')
w = n-r
nya = 0
for i in range(r,n):
    if C[i] == 'R':
        nya += 1
pya = 0
for i in range(r):
    if C[i] == 'W':
        pya += 1
a = 0
for i in range(n-1):
    if C[i] == 'W' and C[i+1] == 'R':
        a += 1
print(min(max(a,cnt), nya, pya))


Measured memory_bytes: 10672
/*
                                                                                                                                               
8b        d8                           888888888888                                             88b           d88                  ad88888ba   
 Y8,    ,8P                                 88                                        ,d        888b         d888                 d8"     "8b  
  Y8,  ,8P                                  88                                        88        88`8b       d8'88                 ""      a8P  
   "8aa8"  ,adPPYba,   88       88          88  8b,dPPYba,  88       88  ,adPPYba,  MM88MMM     88 `8b     d8' 88   ,adPPYba,          ,a8P"   
    `88'  a8"     "8a  88       88          88  88P'   "Y8  88       88  I8[    ""    88        88  `8b   d8'  88  a8P_____88         d8"      
     88   8b       d8  88       88          88  88          88       88   `"Y8ba,     88        88   `8b d8'   88  8PP"""""""         ""       
     88   "8a,   ,a8"  "8a,   ,a88          88  88          "8a,   ,a88  aa    ]8I    88,       88    `888'    88  "8b,   ,aa         aa       
     88    `"YbbdP"'    `"YbbdP'Y8          88  88           `"YbbdP'Y8  `"YbbdP"'    "Y888     88     `8'     88   `"Ybbd8"'         88       
                                                                                                                                               
*/
#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9 + 7;
long long n, m, a[105], dp[100005];

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

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

	cin >> n >> m;
	for (int i = 0; i <= m; i++) {
		dp[i] = 1;
	}

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

		for (int j = m; j >= 0; j--) {
			long long k = j - a[i];
			dp[j] = dp[j];
			if (k > 0) {
				dp[j] = (dp[j] - dp[k - 1] + MOD) % MOD;
			}			
		}

		for (int i = 1; i <= m; i++) {
			dp[i] = (dp[i] + dp[i - 1]) % MOD;
		}
	}

	cout << (dp[m] - dp[m - 1] + MOD) % MOD << '\n';

	return 0;
} 

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

int main(){
    int n, i;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    for(i=n-1; i>=0; i-=2){
        cout << a[i] << ' ';
    }
    if(n%2 == 0){
        i = 0;
    }else{
        i = 1;
    }
    for(; i<n; i+=2){
        cout << a[i] << ' ';
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

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

  vector<int>::iterator it = max_element(a.begin(), a.end());
  int i = distance(a.begin(), it);
  cout << a[i] + b[i] << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, B):
    A = [-1] * N
    A[0] = B[0]
    A[N - 1] = B[N - 2]
    for i in range(1, N - 1):
        A[i] = min(B[i - 1], B[i])
    return sum(A)


def main():
    N = int(inp())
    B = [int(e) for e in inp().split()]
    print(solve(N, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <climits>
#include <vector>
using namespace std;

int main() {
    long n = LONG_MIN;
    cin >> n;
    vector<char> c(n);
    for (int i = 0; i < n; ++i) {
	cin >> c[i];
    }
    int i = 0;
    int j = n-1;
    int cnt = 0;
    while (i < j) {
	while (c[i] == 'R' && i < j) ++i;
	while (c[j] == 'W' && i < j) --j;
	if (i==j) {
	    break;
	} else {
	    cnt += 1;
	    ++i;
	    --j;
	}
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(10**7)
ans=''
def dfs(a,b,c,t):
    global ans
    if a<0 or b<0 or c<0:
        return False
    if t==N:
        return True
    if s[t]=='AB':
        if dfs(a-1,b+1,c,t+1):
            ans+='B'
            return True
        elif dfs(a+1,b-1,c,t+1):
            ans+='A'
            return True
    if s[t]=='BC':
        if dfs(a,b-1,c+1,t+1):
            ans+='C'
            return True
        elif dfs(a,b+1,c-1,t+1):
            ans+='B'
            return True
    if s[t]=='AC':
        if dfs(a+1,b,c-1,t+1):
            ans+='A'
            return True
        if dfs(a-1,b,c+1,t+1):
            ans+='C'
            return True
    return False

N,A,B,C=map(int,input().split())
s=[input() for i in range(N)]

if dfs(A,B,C,0):
    print('Yes')
    print(*ans[::-1],sep='\n')
else:
    print('No')


Measured memory_bytes: 109824
#include "bits/stdc++.h"

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int A() {
	int k, a, b;

	scani(k);
	scani(a);
	scani(b);

	for (int i = a; i <= b; i++) {
		if (0 == i % k) {
			printf("OK");
			return 0;
		}
	}
	printf("NG");


	return 0;
}

int Main() {
	ll wal = 100;
	ll x;
	scanll(x);

	ll y = 1;
	for (; wal < x; y++) {
		wal *= 1.01;
	}
	y -= 1;
	printll(y);
	return 0;
}

int main()
{
	Main();
	return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;

int main(){
  int a,b; cin>>a>>b;
  cout<<6-a-b<<endl;

  return 0;
}


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

using namespace std;

int main()
{
    int a[4], b[4];
    
    while (~scanf("%d%d%d%d\n%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])){
        bool c[10] = {};
        for (int i = 0; i < 4; ++i) c[a[i]] = true;
        int hit = 0, blow = 0;
        for (int i = 0; i < 4; ++i) {
            if (a[i] == b[i]) hit++;
            else if (c[b[i]]) blow++;
        }
        printf("%d %d\n", hit, blow);
    }
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int A[][] = new int[n][m];
        int b[] = new int[m];
        int i,j,c;
        
        for(i=0; i<n; i++){
            for(j=0; j<m; j++){
                A[i][j] = sc.nextInt();
            }
        }
        
        for(j=0; j<m; j++){
            b[j] = sc.nextInt();
        }
        
        for(i=0; i<n; i++){
            c = 0;
            for(j=0; j<m; j++){
                c += ( A[i][j] * b[j] );
            }
            System.out.println(c);
        }
    }
}




Measured memory_bytes: 40848
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define D 1000000007


int main(void){

	long long int N; cin >> N;

	long long int ans = 1;
	FOR(i,1,N+1){
		ans = ((ans%D)*(i%D))%D;
	}

	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    ll H, W;
    cin >> H >> W;
    ll ans;
    if(H == 1 || W == 1) {
        ans = 1;
    } else {
        ans = (H * W + 1) / 2;
    }
    cout << fixed << ans << endl;
}

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

const int MAX = 1234567;

vector<int> g[MAX];
int n;
int dfs (int v, int r) {
	int res = 0;
	for (auto u : g[v])
		if (u != r)
			res ^= dfs (u, v);

	return res + 1;
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i =  0; i < n-1; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	cout << (dfs (0,-1)==1 ? "Bob" : "Alice") << endl;
	return 0;
}


Measured memory_bytes: 36992
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;


  ll H,W;
  string s[100];
  ll cost[55][55];
  vector<pair<ll,ll>> v[100][100];

  bool ser(int y,int x,int c){
      if(cost[y][x]>c){
        cost[y][x]=c;
   
      }
      else{
        return 0;
      }

      for(ll i=0;i<v[y][x].size();i++){
        ser(v[y][x][i].first,v[y][x][i].second,c+1);
      }


      return 1;
  }

ll hh=0;

int main(){
  cin>>H>>W;
  for(ll i=0;i<H;i++){
    cin>>s[i];
 
  }

  for(ll i=0;i<55;i++){
    for(ll j=0;j<55;j++){
      cost[i][j]=123456789;
    }
  }

  
  for(ll i=0;i<H;i++){
  for(ll j=0;j<W;j++){

   if(s[i][j]=='.')
    hh++;

    if(s[i][j]=='.'){
    //right
    if(s[i][j+1]=='.'){
          v[i][j].emplace_back(make_pair(i,j+1));
          v[i][j+1].emplace_back(make_pair(i,j));
    }
    //under
    if(s[i+1][j]=='.'){
          v[i][j].emplace_back(make_pair(i+1,j));
          v[i+1][j].emplace_back(make_pair(i,j));

          
    }
    }



  }
  }


ser(0,0,1);

if(cost[H-1][W-1]!=123456789){
  cout<<hh - cost[H-1][W-1]<<endl;
}
  else{
    cout<<-1<<endl;
  }

}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
int main(){
	int n;
	cin>>n;
	int a[n+1];
	a[n]=0;
	in(a,n);
	ll count=0;
	rep(i,n){
		count+=a[i]/2;
		if(a[i]%2&&a[i+1]){
			count++;
			a[i+1]--;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const LL MOD = 1000000007;

int N;
LL dp[MAXN][2];
vector<int> G[MAXN];

void dfs(int v, int p) {
	dp[v][0] = dp[v][1] = 1;
	
	for (int to : G[v]) {
		if (to == p) continue;
		dfs(to, v);
		dp[v][0] = dp[v][0] * (dp[to][0] + dp[to][1]) % MOD;
		dp[v][1] = dp[v][1] * dp[to][0] % MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	
	dfs(1, 1);
	cout << (dp[1][0] + dp[1][1]) % MOD;
}


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

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

  int x;
  std::cin >> x;

  int fh_count = x / 500;
  int f_count = (x % 500) / 5 ;

  std::cout << fh_count * 1000 + f_count * 5 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int main()
{
  int N, M; cin >> N >> M;
  vector<int> aba(M);
  rep(i, 0, M) cin >> aba[i];
  vector<int> value(10);
  value[1] = 2;
  value[2] = 5;
  value[3] = 5;
  value[4] = 4;
  value[5] = 5;
  value[6] = 6; 
  value[7] = 3;
  value[8] = 7;
  value[9] = 6;
  vector<string> dp(N + 10, "0");
  dp[0] = "";

  repe(num, 0, N){
    if(dp[num] == "0") continue;
    rep(i, 0, M){
      int next = num + value[aba[i]];
      if(dp[next] == "0"){
        dp[next] = dp[num] + (char)('0' + aba[i]);
      }else if(dp[next].size() < dp[num].size() + 1) {
        dp[next] = dp[num] + (char)('0' + aba[i]);
      } else if(dp[next].size() == dp[num].size() + 1){
          if(dp[next] < dp[num] + (char)('0' + aba[i])) dp[next] = dp[num] + (char)('0' + aba[i]);
      }
    }
  }

  cout << dp[N] << endl;

}

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

int main(){
  int X; cin >> X;
  
  if(X == 2){
    cout << 2 << endl;
    return 0;
  }
  
  while(1){
    for(int i=2; i<X; i++){
      if(X%i ==0)
        break;
      
      if(i == X-1){
        cout << X << endl;
        return 0;
      }
    }
    X++;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RG register
#define MAXN 110

using namespace std;

int n;
double a[MAXN];
double ans;

int main() {
    ans = 0.0;
  	cin >> n;
  	for(RG int i = 1; i <= n; ++i) cin >> a[i];
  	for(RG int i = 1; i <= n; ++i) ans += (double) (1 / a[i]);
  	cout << 1 / ans << endl;
  	return 0;
}

Measured memory_bytes: 256
import numpy as np
k,n=map(int,input().split())
a=np.array(list(map(int,input().split())))

a_diff=np.diff(a)
a_diff2=(k - a[n-1])+a[0]
diff_max=np.max(np.append(a_diff,a_diff2))
print(k-diff_max)


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
const int N = (int)1e6+10;

int f[N];


lli pow1(lli x, lli y) {
  lli ans = 1;
  x %= MOD;
  while(y>0) {
    if(y&1LL) ans = (ans * x) % MOD;
    x = (x * x) % MOD;
    y = y >> 1;
  }
  return ans;
}

lli inv(lli x) {
  return pow1(x, MOD-2);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi a(n);
  memset(f, 0, sizeof f);
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) {
    int x = a[i];
    for(int j = 2; j*j <= a[i]; j++) {
      if(x%j == 0) {
        int cnt = 0;
        while(x % j == 0) {
          x /= j;
          cnt++;
        }
        f[j] = max(f[j], cnt);
      }
    }
    if(x != 1) {
      f[x] = max(f[x], 1);
    }
  }
  lli p = 1;
  rep(i,1,N) {
    p *= pow1(i, f[i]);
    p %= MOD;
  }
  lli ans = 0;
  rep(i,0,n) {
    ans += p * inv(a[i]) % MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    map<char, ll> M;
    REP(i, S.length()){
        M[S[i]]++;
    }
    for(char c='a'; c<='z'; c++){
        if(!M.count(c)){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>v;
const int MAX = 2e5 +5;
int rail[MAX],road[MAX];

int road_f(int x) {
  if (road[x] == x)return x;
  else return road[x] = road_f(road[x]);
}
int rail_f(int x) {
  if (rail[x] == x)return x;
  else return rail[x] = rail_f(rail[x]);
}
int main() {
  int n,k,l,x,y;
  scanf("%d%d%d",&n,&k,&l);
  for (int i = 1; i <= n; ++i)road[i] = rail[i] = i;
  for (int i = 0; i < k; ++i) {
    scanf("%d%d",&x,&y);
    x = road_f(x),y = road_f(y);
    road[x] = y;
  }
  for (int i = 0; i < l; ++i) {
    scanf("%d%d",&x,&y);
    x = rail_f(x),y = rail_f(y);
    rail[x] = y;
  }
  for (int i = 1; i <= n; ++i) {
    road[i] = road_f(i);
    rail[i] = rail_f(i);
    v[make_pair(road[i],rail[i])]++;
  }
  for (int i = 1; i < n; ++i) {
    printf("%d ",v[make_pair(road[i],rail[i])]);
  }
  printf("%d\n",v[make_pair(road[n],rail[n])]);
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#include <list>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 100000007;
using Graph = vector<vector<int>>;


int main(){
    float L;
    cin >> L;
    float V;
    L/= 3;
    V=L*L*L;
    cout << setprecision(16);
    cout << V << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long L, R; cin >> L >> R; 
	long long MOD = 1000000007; 
	long long ans = 0;
	for(int d = 1; d <= 60; d++){
		long long left = (1LL << (d-1)); long long right = (1LL << d); 
		if(L >= right || R < left) continue; 
		long long dp[62][2][2] = {}; // dp[i桁目][xの以上確定][yの以下確定]
		if(L < left && R >= right) dp[0][1][1] = 1; 
		else if(L < left) dp[0][1][0] = 1; 
		else if(R >= right) dp[0][0][1] = 1; 
		else dp[0][0][0] = 1; 
		for(int t = 1; t < d; t++){
			bool a = (max(L, left) >> (d-1-t)) & 1; 
			bool b = (min(R, right-1) >> (d-1-t)) & 1; 
			if(!a & !b){
				dp[t][0][0] = dp[t-1][0][0]; 
				dp[t][0][1] = dp[t-1][0][1] * 2 % MOD;
				dp[t][1][0] = dp[t-1][1][0]; 
				dp[t][1][1] = (dp[t-1][0][1] + dp[t-1][1][1] * 3) % MOD; 
			}
			else if(!a & b){
				dp[t][0][0] = dp[t-1][0][0]; 
				dp[t][0][1] = (dp[t-1][0][0] + dp[t-1][0][1] * 2) % MOD;
				dp[t][1][0] = (dp[t-1][0][0] + dp[t-1][1][0] * 2) % MOD;
				dp[t][1][1] = (dp[t-1][0][1] + dp[t-1][1][0] + dp[t-1][1][1] * 3) % MOD; 
			}
			else if(a & !b){
				dp[t][0][1] = dp[t-1][0][1];
				dp[t][1][0] = dp[t-1][1][0];
				dp[t][1][1] = dp[t-1][1][1] * 3 % MOD; 
			}
			else if(a & b){
				dp[t][0][0] = dp[t-1][0][0]; 
				dp[t][0][1] = dp[t-1][0][1];
				dp[t][1][0] = dp[t-1][1][0] * 2 % MOD; 
				dp[t][1][1] = (dp[t-1][1][0] + dp[t-1][1][1] * 3) % MOD; 
			}
		}
		long long tmp = dp[d-1][0][0] + dp[d-1][0][1] + dp[d-1][1][0] + dp[d-1][1][1]; 
		ans += tmp; ans %= MOD; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  bool bl = true;
  if (N%2) {
    bl = false;
  } else {
    rep(i, N/2) {
      if (S[i] != S[i+N/2]) {
        bl = false;
      }
    }
  }
  if (bl) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

Int gcd(Int a, Int b) {
	return (b ? gcd(b, a % b) : a);
}

Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	cout << lcm(2,N) << "\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


long long f(long long x) {
    int cnt = 0;
    for (int i = 0; i < 20; i++) {
        cnt += (x >> i) & 1;
    }
    return x % cnt;
}

long long modpow(int p, long long m) {
    long long ret = 1;
    long long b = 2;
    for (int i = 0; i < 20; i++) {
        if ((p >> i) & 1) ret = ret*b % m;
        b = b*b % m;
    }
    return ret;
}

int main() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    std::vector<long long> m(3), r(3);
    for (int i = 0; i < n; i++) m[1] += s[i] == '1';
    m[0] = m[1] - 1;
    m[2] = m[1] + 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            if (m[j] == 0) continue;
            r[j] = (r[j] * 2 + (s[i] == '1')) % m[j];
        }
    }
    for (int i = 0; i < n; i++) {
        int id = s[i] == '1' ? 0 : 2;
        if (m[id] == 0) {
            std::cout << 0 << std::endl;
            continue;
        }
        int ans = 1;
        long long q = (r[id] + m[id] + (id - 1)*modpow(n - 1 - i, m[id]) % m[id]) % m[id];
        while (q != 0) {
            q = f(q);
            ans++;
        }
        std::cout << ans << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;cin >> a >> b >> c;
	ll x,y;cin >> x >> y;
	ll ans = 1e10;
	rep(i,max(x,y) + 1){
		ll sum = i * c * 2;
		sum += max(0LL, x - i) * a + max(0LL, y - i) * b;
		ans = min(ans, sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool debug;
#define all(x) (x).begin(), (x).end()
#define ll long long

#define db(x) if(debug)cout << " " << (x) <<" "
#define dbn(x) if(debug)cout << "\n" << (#x) << " is " << (x) << endl
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
// fill(all(vec), 1);
//vec.resize(unique(all(vec))-vec.begin())
const int N = 3e6;
std::vector<ll> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
void solve()
{
    ll n = 32, i, j, x, y;
    cin>>n;
    cout<<v[n-1]<<endl;


}



int main()
{
    debug = 0;


    if(debug)
    {
#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
#endif
    }

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;


    while(t--)
    {
        solve();
        // cout << endl;
    }


}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, K; cin >> N >> K;
    vector<ll> v;
    REP(i, N) {
        ll tmp; cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end(),greater<ll>());
    ll num_attack = 0;
    for (ll i = K; i < N; i++) {
        num_attack += v[i];
    }
    cout << num_attack << endl;
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long result = 0;

        // 素数の場合
        if (isPrime(n)) {
            result = n - 1;

        } else {

            // 平方根が整数の場合
            double sqrt = Math.sqrt(n);
            if (sqrt - (int) sqrt == 0) {
                result = (int) sqrt * 2 - 2;

            } else {

                long preNum = 0;
                for (long i = 2; i <= n / 2 && result == 0; i++) {
                    if (n % i == 0) {
                        if (isPrime(n / i)) {
                            result = n / i + i - 2;

                        } else if (preNum * i == n) {
                            result = preNum + i - 2;
                        }
                        preNum = i;
                    }
                }
            }
        }

        System.out.println(result);
    }

    public static boolean isPrime(long num) {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.sqrt(num);
        for (long i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}


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

typedef unsigned long long int ull;
typedef long long ll;
#define pb push_back

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //your code starts here
    string s;
    cin >> s;
    int ctr = 0, n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            //++ctr;
            int c = 1;
            for (int j = i + 1; j < n; j++)
            {
                if (s[j] == 'R')
                    ++c;
                else
                    break;
            }
            i += (c - 1), ctr = max(ctr, c);
        }
    }
    cout << ctr << "\n";

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int A[200001];
int B[200001];
vector<int>v[200001];
vector<LL>w[200001];

LL MOD=1e9+7;



LL pp(LL x, LL y){
	LL temp=y;
	LL ans=1;
	LL now=x;
	while(temp!=0){
		if(temp%2==1){
			ans*=now;
			ans%=MOD;
		}
		temp/=2;
		now=now*now;
		now%=MOD;
	}
	return ans;
}

LL inv(LL x){
	return pp(x,MOD-2);
}

int dfs(int x, int p){
	int temp=1;
	if(v[x].size()==1&&p!=-1){
		w[x].push_back(N-1);
		return 1;
	}
	REP(i,v[x].size()){
		if(v[x][i]!=p){
			LL now=dfs(v[x][i], x);
			w[x].push_back(now);
			temp+=now;
		}
	}
	w[x].push_back(N-temp);
	return temp;
}

int main(){
	cin>>N;
	REP(i,N-1){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		v[A[i]].push_back(B[i]);
		v[B[i]].push_back(A[i]);
	}
	dfs(0,-1);
	LL ans=0;
	REP(i,N){
		LL temp=pp(2,N-1);
		REP(j,v[i].size()){
			LL temp2=pp(2,w[i][j]);
			//LL temp3=pp(2,N-w[i][j]-1);
			//cout<<w[i][j]<<" "<<i<<" "<<j<<" "<<temp2<<" "<<temp3<<endl;
			//temp2*=temp3;
			temp2%=MOD;
			
			temp-=temp2;
			temp+=MOD;
			temp%=MOD;
			//cout<<i<<" "<<j<<" "<<temp<<endl;
		}
		temp+=(v[i].size()-1);
		temp%=MOD;
		ans+=temp;
		ans%=MOD;
		//cout<<"ans"<<ans<<endl;
	}
	ans=ans*(inv(pp(2, N)));
	ans%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 39552
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]

if x==y:
  print("Yes")
else:
  if (x in a and y in a) or (y in b and x in b):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int a, b;
	cin >> a >> b;
	if (a * b & 1) puts("Odd");
	else puts("Even");
	return 0;
}

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

int main(){
    int a,b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if(op == '+'){
            cout << a + b << endl;
        }else if(op == '-'){
            cout << a - b << endl;
        }else if(op == '*'){
            cout << a * b << endl;
        }else if(op == '/'){
            cout << a / b << endl;
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
I=lambda:int(input())
MI=lambda:map(int,input().split())
LI=lambda:list(map(int,input().split()))

N=I()

if N%2:
    print(0)
else:
    res=0
    i=1
    while 1:
        dr=N//(2*5**i)
        if dr:
            res+=dr
        else:
            break
        i+=1
    print(res)
        

Measured memory_bytes: 61792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  rep (i, q) {
    int tmp;
    cin >> tmp;
    a[tmp - 1]++;
  }

  rep (i, n) {
    if (k - (q - a[i]) > 0) Yes;
    else No;
  }

  return 0;
}





Measured memory_bytes: 1024
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		String s = sc.next();
		int n = sc.nextInt();
		for (int i=0; i<n; i++) {
			String mode = sc.next();
			int a = sc.nextInt(); int b = sc.nextInt();
			if (mode.equals("print")) {
				System.out.println(s.substring(a,b+1));
			}
			else if (mode.equals("reverse")) {
				s = s.substring(0,a) + (new StringBuilder(s.substring(a,b+1)).reverse().toString()) + (s.substring(b+1,s.length()));
			}
			else if (mode.equals("replace")) {
				String t = sc.next();
				s = s.substring(0,a) + t + s.substring(b+1,s.length());
			}
		}
		
	}
}


Measured memory_bytes: 29556
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

map<char,char> opposite = {{'N','S'}, {'S','N'}, {'W', 'E'}, {'E', 'W'}};
set<char> present;

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

	string s; cin >> s;
	for (char c : s) present.insert(c);
	
	for (char c : present) {
		if (present.find(opposite[c]) == present.end()) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


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

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

const int MAXN = 1e5;

struct Data { int s, e; };

int N;
Data A[MAXN+10];

int main()
{
	int i, j;

	scanf("%d", &N);
	for(i=1; i<=N; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		A[i]={a-b, a+b};
	}

	sort(A+1, A+N+1, [&](const Data &p, const Data &q) { return p.e<q.e; });

	int bef=-2e9, ans=0;
	for(i=1; i<=N; i++)
	{
		if(bef>A[i].s) continue;
		ans++;
		bef=A[i].e;
	}
	printf("%d", ans);
}

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

def main():
    sa = input().split(' ')
    S = input()
    A = int(sa[0])
    B = int(sa[1])

    correct = True
    if len(S) != A + B + 1:
        correct = False
    else:
        for i in range(A + B + 1):
            if i == A:
                if S[i] != '-':
                    correct = False
                    break
            else:
                if S[i] < '0' or '9' < S[i]:
                    correct = False
                    break

    print('Yes' if correct else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int n;
    bool f=false;
    while(cin>>n,n){
        if(f) cout<<endl;
        f=true;
        vint v(4);
        rep(i,4){
            cin>>v[i];
        }
        vint w={10,50,100,500};
        int tmp=0;
        rep(i,4) tmp+=v[i]*w[i];
        int t=tmp-n;
        vint x(4);
        for(int i=3;i>=0;i--){
            while(t>=w[i]) x[i]++,t-=w[i];
        }
        rep(i,4){
            if(v[i]-x[i]>0) cout<<w[i]<<" "<<v[i]-x[i]<<endl;
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

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

int first = 0, second = 0, third = 0;

//???????????¨
void sort(){
	int buf = third;
	if(third > first){
	//3rd > 1st??????,1->2 2->3 3->1?????????
		third = second;
		second = first;
		first = buf;
	}else if(third > second){
	//3rd > 2nd??????,2->3 3->2?????????
		third = second;
		second = buf;
	}
}

int main(){
int buf;

for(int i = 0; i < 10; i++){
	cin >> buf;
	//3rd????????§?????????????????????
	if(buf > third){
		third = buf;
		sort();
	}
}

//??¨???
cout << first << "\n";
cout << second << "\n";
cout << third << "\n";

return 0;
}

Measured memory_bytes: 1164
N = int(input())

x = []
y = []
for i in range(N):
    _x, _y = [int(x) for x in input().split()]
    x.append(_x)
    y.append(_y)


def CalDistence(x0, y0, x1, y1):
    return (((x0 - x1) ** 2) + (y0 - y1) ** 2) ** 0.5


AllDistance = 0
for i in range(N):
    for j in range(N):
        if i != j:
            AllDistance += CalDistence(x[i], y[i], x[j], y[j])

print(AllDistance / N)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <set> 
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   if(a<=8 and b<=8) cout<<"Yay!"<<endl;
   else cout<<":("<<endl;
   

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a==b){
			System.out.println(c);
		}
		else if (a==c){
			System.out.println(b);
		}
		else {
			System.out.println(a);
		}
		
		
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int A[3], K;
	int tmp;
	int ans = 0;
	for (int i = 0; i < 3; i++)
	{
		cin >> A[i];
	}
	cin >> K;

	tmp = *max_element(A, A + 3);

	for (int i = 0; i < 3; i++)
	{
		ans += A[i];
	}

	ans -= tmp;

	for (int i = 0; i < K; i++)
	{
		tmp *= 2;
	}

	ans += tmp;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n,h=map(int, input().split())
a=[]
b=[]
for i in range(n):
    ai,bi=map(int, input().split())
    a.append(ai)
    b.append(bi)
b=sorted(b,reverse=True)
amax=max(a)
newb=[0]
for i in range(n):
    if b[i]>amax:
        newb.append(b[i])
from itertools import accumulate
newb=list(accumulate(newb))
ans=0
for i in range(len(newb)):
    if newb[i]>=h:
        ans=i
        break
if ans==0:
    ans+=len(newb)-1
    ans+=(h-max(newb))//amax
    if (h-max(newb))%amax>0:
        ans+=1
print(ans)

Measured memory_bytes: 69592
#include<bits/stdc++.h>
using namespace std;
int min(int a,int b){
    if(a<b) return a;
    else return b;
}
int he[100005],dp[100005];
int cost(int i,int n,int k){
    if(dp[i]!=-1) return dp[i];
    int result;
    if(i==n) result=0;
    
    else{
        int x=-1;
        for(int j=i+1;j<=n;j++){
            int a;
            a=abs(he[i]-he[j])+cost(j,n,k);
            
            if(x==-1) x=a;
            x=min(x,a);
            if(j-i==k) break;
        }
        result=x;
    }
    dp[i]=result;
    
    return dp[i];
}
int main(){
    int n,k;
    cin >> n >> k;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        cin >> he[i];
    }
    cout << cost(1,n,k) << endl;
    
}

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

using namespace std;

int main(void){
  int i, answer;
  string S;
  // get input --------------------------------------
  cin >> S;
  // count -----------------------------------------
  answer = 0;
  for(i = 0; i < S.size() / 2; i++) {
    if(S[i] != S[S.size() - i - 1]) {
      answer++;
    }
  }
  // disp answer -----------------------------------
  cout << answer << endl;
  return 0;
}








Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n, h[101];
	int i, j, k;
	int sa[101], b[101];
	int flg;

	scanf("%d", &n);
	while (n != 0) {
		for (i = 0; i<n + 1; i++) {
			scanf("%d", &h[i]);
		}
		for (i = 0; i<n + 1; i++) {
			k = 0;
			for (j = 0; j<n + 1; j++) {
				if (i != j) {
					b[k] = h[j];
					k++;
				}
			}
			for (j = 0; j<n - 1; j++) {
				sa[j] = b[j + 1] - b[j];
			}
			flg = 0;
			for (j = 0; j<n - 2; j++) {
				if (sa[j] != sa[j + 1]) {
					flg = 1;
				}
			}
			if (flg == 0) {
				printf("%d\n", h[i]);
				break;
			}
		}
		scanf("%d", &n);
	}
	return 0;
}

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

int main() {
  int m, min, max, su, gap, temp;
  vector<int> p;

  while(1) {
    cin >> m >> min >> max;
    if(m == 0 && min == 0 && max == 0)
      break;

    for(int i = 0; i < m; i++) {
      int P;
      cin >> P;
      p.push_back(P);
    }

    // sort(p.begin(), p.end(), greater<int>());                               

    su = p[min-1]-p[min];
    gap = min;
    for(int i = min-1; i < max; i++) {
      temp  = p[i] - p[i+1];
      //cout << temp << ' ' << gap << endl;                                    
      if(temp >= su) {
        su = temp;
        gap = i+1;
      }
    }
    cout << gap << endl;
    p.clear();
  }

  return 0;
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

vector<ll> adj[200005];
vector<ll> ar(200005);
bool visited[200005]={false};
vector<ll> final;
ll idx=0;
ll cycstno=1;
ll cycendidx=0;

void dfs(ll node)
{
    visited[node]=true;
    ar[idx]=node;
    idx++;

    for(auto i:adj[node])
    {
        if(!visited[i])
        dfs(i);
        else
        {
            cycstno=i;
            cycendidx=idx;
        }
        
    }
}

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll n,k;
        cin>>n>>k;

        for(ll i=1;i<=n;i++)
        {
            ll x;
            cin>>x;

            adj[i].pb(x);
        }

        dfs(1);
        ll flag=0;

        for(ll i=0;i<cycendidx;i++)
        {
            if(flag==0)
            {
                if(ar[i]==cycstno)
                {
                    final.pb(ar[i]);
                    flag=1;
                }
                else
                {
                    if(k!=0)
                    k--;
                    else
                    {
                        cout<<ar[i];
                        return 0;
                    }
                    
                }
                
            }
            else
            {
                final.pb(ar[i]);
            }
            
        }

        k=k%final.size();

        // for(auto i:final)
        // cout<<i<<' ';
        // cout<<endl;

        cout<<final[k];

    }
}














Measured memory_bytes: 22992
S = [0]*17
Q = []
W = [0]*100
 
def check(I):
  n = [2,5][I%5==1]
  for s in range(17-n+1):
    if S[s:s+n] == [0]*n: return s
  return -1

t = 0
c = 0
while c<100:
  for i in range(S.count(t)): S[S.index(t)]=0
  if t<500 and t%5==0: Q.append(t/5)
  
  while len(Q)>0:
    s = check(Q[0])
    if s==-1: break
    I = Q.pop(0)
    n = [2,5][I%5==1]
    S[s:s+n] = [t+ 17*(I%2) + 3*(I%3) + 19] * n
    W[I] = t - I*5
    c += 1
  t += 1
 
while 1:
  try: print W[int(raw_input())]
  except: break

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum=0;
  // ここにプログラムを追記
  for(int i=0;i<N;i++){
    int seatF,seatE;
    cin>>seatF>>seatE;
    
    sum+=seatE-seatF+1;
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n; cin>>n;
  int p=1000000007;
  int64_t a=1,b=1,c=1;
  for (int i=0; i<n; i++) {
    a = a * 10 % p;
    b = b *  9 % p;
    c = c *  8 % p;
  }
  cout << (a - b * 2 + c + p * 2) % p << endl;
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n, k;
    cin >> n >> k;
    vector< int> v(n);
    for (int &e : v) cin >> e;
    sort(begin(v), end(v));
    while (!v.empty() && k > 0) {
        k--;
        v.pop_back();
    }

    LL result = accumulate(begin(v), end(v), 0LL);
    cout << result << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k,d,ans;
int flag[105];

int main()
{

	cin>>n>>k;
	while(k--){
		cin>>d;
		int tmp;
		while(d--){
			cin>>tmp;
			flag[tmp]++;
		}
	}
	for(int i=1;i<=n;i++){
		if(flag[i])ans++;
	}
	//cout<<endl;
	cout<<n-ans;
	return 0;
}

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

vector<int> G[102];
int d[102];

int main()
{
    int n,u,k,v;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> u >> k;
        for(int j = 0; j < k; ++j){
            cin >> v;
            G[u].push_back(v);
        }
    }
    
    fill(d,d + n + 1, -1);
    
    queue<int> que;
    que.push(1);
    d[1] = 0;
    while(!que.empty()){
        int p = que.front(); que.pop();
        for(vector<int>::iterator it = G[p].begin(); it != G[p].end(); ++it){
            if(d[*it] == -1){
                d[*it] = d[p] + 1;
                que.push(*it);
            }
        }
    }
    
    for(int i = 1; i <= n; ++i){
        cout << i << ' ' << d[i] << endl;
    }
}

Measured memory_bytes: 1228