akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=[int (x) for x in input().split()]

rainbow=0
rate=[]

for i in A:
    if (i>=3200):
        rainbow+=1
    else:
        rate.append(i//400)
#print(rate)
cnt=len(set(rate))
print(max(1,cnt),cnt+rainbow)
    

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

int main() {
 char x;
 cin >> x;
 if (x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o')
   cout << "vowel" << endl;
  else
   cout << "consonant" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[100010];
multiset<int>st;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	for(int i=n-1;i>=0;i--){
		if(st.upper_bound(a[i])==st.end())st.insert(a[i]);
		else{
			st.erase(st.upper_bound(a[i]));
			st.insert(a[i]);
		}
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
    ll n;
    cin>>n;
    ll ar[n];
    for(int i=0;i<n;i++)
    {
    	cin>>ar[i];
    }
    ll su = 0;
    for(int i=0;i<n-1;i++)
    {
    	if(ar[i] == ar[i+1])
    	{
           continue;
    	}
    	else if(ar[i]>ar[i+1])
    	{
    		su+=(ar[i]-ar[i+1]);
    		ar[i+1] = ar[i];
    	}
    	else 
    	{
    		continue;
    	}
    }
    cout<<su<<"\n";
}

Measured memory_bytes: 5152
local n,k=io.read("n","n")
local t={}
for i=1,n do
    local a,b=io.read("n","n")
    t[i]={a,b}
end
table.sort(t,function(x,y)
    return x[1]<y[1]
end)

local counter=0
for i=1,n do
    counter=counter+t[i][2]
    if counter>=k then
        print(t[i][1])
        return
    end
end

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

const int INF = 200005;
int main() {
    int n;
    cin >> n;
    vector<int> P(n);
    for (int i = 0; i < n; ++i) {
        cin >> P[i];
    }
    int minp = INF;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (minp > P[i]) {
            ans++;
            minp = P[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<short,short> pii;
const int MOD = 1e9 + 7;
const int N = 8000+50;
const int offset = 2000 + 10;
 
LL quick_inverse(LL n) {
	LL ret = 1;
	int exponent = MOD - 2;
	for (int i = exponent; i; i >>= 1, n = n * n % MOD) {
		if (i & 1) {
			ret = ret * n % MOD;
		}
	}
	return ret;
}
 
LL invf[N], factor[N];
void get_factorial_inverse(int n) {
	factor[0] = 1;
	for (int i = 1; i <= n; ++i) {
		factor[i] = i * factor[i - 1] % MOD;
	}
	invf[n] = quick_inverse(factor[n]);
	for (int i = n-1; i >= 0; --i) {
		invf[i] = invf[i + 1] * (i + 1) % MOD;
	}
}
 
int A[200010], B[200010];
 
LL Map[offset*2+10][offset*2+10];
bool vis[offset*2+10][offset*2+10];
 
LL calc_x(int n)
{
    LL ans = 0;
    int max_range = 0;
    for (int i=1; i<=n; i++)
    {
        Map[offset + A[i]][offset + B[i]]++;
        Map[offset - A[i]][offset - B[i]]++;
        max_range = max(max_range, A[i]);
        max_range = max(max_range, B[i]);
    }
    queue<pii> q;
    q.push(pii(offset + max_range, offset + max_range));
    vis[offset + max_range][offset + max_range] = true;
    while(!q.empty())
    {
        pii node = q.front(); q.pop();
        int x = node.first, y = node.second;
        if (x < offset && y < offset && Map[x][y])
        {
            LL times = Map[x][y];
            Map[x][y] = (Map[x+1][y] + Map[x][y+1]) % MOD;
            ans += (times * Map[x][y]) % MOD;
        }
        else
        {
            if (x < offset + max_range) Map[x][y] += Map[x+1][y];
            if (y < offset + max_range) Map[x][y] += Map[x][y+1];
            Map[x][y] %= MOD;
        }
        if (x > offset - max_range && !vis[x-1][y])
            q.push(pii(x-1,y)), vis[x-1][y] = true;
        if (y > offset - max_range && !vis[x][y-1])
            q.push(pii(x,y-1)), vis[x][y-1] = true;
    }
    return ans;
}
 
LL f(int x, int y)
{
    return (((factor[x+y] * invf[x]) % MOD) * invf[y]) % MOD;
}
 
LL calc_t(int n)
{
    LL ans = 0;
    for (int i=1; i<=n; i++)
        ans = (ans + f(2*A[i], 2*B[i])) % MOD;
    return ans;
}
 
int main()
{
    get_factorial_inverse(8010);
    int n;
    scanf("%d", &n);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d", A+i, B+i);
    }
    LL ans = 0;
    ans += calc_x(n);
    ans -= calc_t(n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    ans *= invf[2];
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    cout << ans;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int h[100010];
	int i;
	for(i=0; i<N; ++i) cin >> h[i];
	sort(h, h+N);
	int sa=h[K-1]-h[0];
	for(i=1; i+K<=N; ++i) if(h[i+K-1]-h[i]<sa) sa=h[i+K-1]-h[i];
	cout << sa << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
using namespace std;

const int INT__MAX = 2147483647;
const int MOD = 1000000007;

int main() {

	int A, B, C, D;

	cin >> A >> B >> C >> D;

	if (B <= C)cout << 0 << endl;
	else if (D <= A)cout << 0 << endl;
	else if (A <= C&&C <= B&&B <= D)cout << B - C << endl;
	else if (A <= C&D <= B)cout << D - C << endl;
	else if (C <= A&&A <= D&&D <= B)cout << D - A << endl;
	else if (A <= C&&C <= B&&B <= D)cout << B - C << endl;
	else if (C <= A&&B <= D)cout << B - A << endl;
	else if (C <= A&&A <= D&&D <= B)cout << D - A << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstring>
#include <queue>
using namespace std;
const int N = 1e5 + 7;
struct Edge {
	int to, nxt, w;
}e[N << 1];
long long dis[N];
int cur, head[N];
bool vis[N];
void init() {
	cur = 0;
	memset(head, -1, sizeof head);
	memset(vis, 0, sizeof vis);
}
void add(int u, int v, int w) {
	e[cur].to = v;
	e[cur].w = w;
	e[cur].nxt = head[u];
	head[u] = cur++;
}
void bfs(int rt) {
	dis[rt] = 0;
	vis[rt] = 1;
	queue<int> q;
	q.push(rt);
	while (!q.empty()) {
		rt = q.front(); q.pop();
		for (int i = head[rt]; ~i; i = e[i].nxt) {
			int v = e[i].to;
			if (!vis[v]) {
				vis[v] = 1;
				dis[v] = dis[rt] + e[i].w;
				q.push(v);
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n) {
		init();
		int u, v, w, q, k;
		for (int i = 1; i < n; ++i) {
			cin >> u >> v >> w;
			add(u, v, w);
			add(v, u, w);
		}
		cin >> q >> k;
		bfs(k);
		while (q--) {
			cin >> u >> v;
			cout << dis[u] + dis[v] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 5376
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).map {|i| [i, 1] }

m.times.map do
  a << gets.split.map(&:to_i).reverse
end

ans = 0
count = n

a.sort.reverse.each do |(val, num)|
  if count > num
    ans += val * num
    count -= num
  else
    break ans += val * count
  end
end

puts ans


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

int main( void )
{
    char s[ 11 ];
    cin >> s;
    s[ 0 ] = '2';
    s[ 1 ] = '0';
    s[ 2 ] = '1';
    s[ 3 ] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
t = ?_*N
$<.each{|ln|
	s, c = ln.split
	s = s.to_i-1
	t[s] = c if t[s] == ?_
	(p(-1); exit) if t[s] != c
}
t[0] = ?1 if 1<N and t[0] == ?_
N.times{|s|
	t[s] = ?0 if t[s] == ?_
}
puts(
	if 1<N and t[0]==?0
		-1
	else t end
)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int a,ans=0,sjx=0;
string x;
int main()
{
	cin>>a>>x;
	for(int i=0;i<a;i++)
	{
		if(x[i]=='I')
			sjx=sjx+1;
		if(x[i]=='D')
			sjx=sjx-1;
		if(sjx>ans)
			ans=sjx;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c,n,cnt=0;
  cin>>a>>b>>c>>n;
  for(int A=0;A<=a;A++)
    for(int B=0;B<=b;B++)
      for(int C=0;C<=c;C++)
        if(500*A+100*B+50*C==n)cnt++;
  cout<<cnt<<endl;
}

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

int main(){
  int A,B,count=0;
  cin >> A >> B;
  for(int i=0;i<=B-A;i++){
    int num = A + i;
    std::string str;
    str = std::to_string(num);
    if(str.at(0) == str.at(4) && str.at(1) == str.at(3)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3640
//https://atcoder.jp/contests/abc142/tasks/abc142_b
#include<bits/stdc++.h>
using namespace std;
#define aakriti long long int
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        aakriti n , k, count{0};
        cin >> n >> k ;
        while(n--)
        {
                int x ;
                cin >> x ;
                if ( x >= k ) count++;
        }
        cout << count << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ll n,a; cin>>n;
ll count=0;

for(ll i=0; i<n; i++){
cin>>a;
if( (a%2==0) && (a%3==0 || a%5==0)){
  count+=0;
}else{
  if( a%2!=0 ){
    count+=0;
  }else{
    count+=1;
  }
}
}

if(count==0){
cout << "APPROVED" << endl;
}else{
cout << "DENIED" << endl;
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn=1000000;
int h[maxn];// f[i]表示到达第i个点的 最小花费  
ll f[maxn];
ll Max=10000000000LL;
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&h[i]);
	for (int i=2;i<=n;i++) f[i]=Max;
	f[2]=abs(h[2]-h[1]);
	for (int i=3;i<=n;i++) 
		for (int j=1;j<=2;j++){
			f[i]=min(f[i-j]+abs(h[i]-h[i-j]),f[i]);
		}
	cout<<f[n];
	return 0;
} 

Measured memory_bytes: 5120
N, A, B = map(int, input().split())

if A == 0:
    print(0)
elif B == 0:
    print(N)
else:
    br_block = A + B
    pre_b = (N - 1) // br_block
    if (N - 1) % br_block < A:
        b = (N - 1) % br_block + 1
    else:
        b = A
    print(A * pre_b + b)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readInt64() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

const INF = int(1e4) + 1

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = readInt64()
	}

	dp := make([]int, n)
	for i := 1; i < n; i++ {
		dp[i] = INF
	}

	dp[0] = 0
	dp[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
	}
	fmt.Println(dp[n-1])
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if (a + b == 15)
            System.out.println("+");
        else if (a * b == 15)
            System.out.println("*");
        else
            System.out.println("x");
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> counts(M, 0);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int x;
      cin >> x;
      counts[x - 1]++;
    }
  }

  int answer = 0;
  for (int i = 0; i < M; i++) {
    if (counts[i] == N) {
      answer++;
    }
  }
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
/*

        শুভ নববর্ষ ।
        ঘরে থাকুন , সুস্থ থাকুন ।
    wan-_-s
*/

#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
const ll N = 200007 ;
map<ll,ll> mp ;
void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=1 ;i<n;i++) { scanf("%lld",&v[i]) ;mp[v[i]]++ ; } }
vector<ll> adj[N] ;
ll vis[N] , lvl[N] ,lvl1[N],vis1[N] ;
void edge (ll u , ll v) {
    adj[u].pb(v) ;
    adj[v].pb(u) ;
}


int main() {

   ll n , m ;
   cin >> n ;
   vector<ll> v(n) ;
   scan(v) ;
   ll sum = 0 ;
   for(ll i=1;i<=n;i++)
cout << mp[i] << endl ;
    stay_home_stay_safe ;
}






Measured memory_bytes: 22064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> c(n);
    rep(i, n) cin >> c[i];

    vector<int> nxt(n);
    vector<int> last(2e5+1, INF);
    for(int i = n - 1; i >= 0; i--){
        nxt[i] = last[c[i]];
        last[c[i]] = i;
    }

    vector<int> dp(n + 1);
    dp[0] = 1;
    rep(i, n){
        dp[i+1] += dp[i];
        dp[i+1] %= MOD;
        if(nxt[i] != INF && i + 1 != nxt[i]){
            dp[nxt[i]] += dp[i];
            dp[nxt[i]] %= MOD;
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 7160
#include<iostream>
using namespace std;
int main(){
	int n,m,c;
	cin>>n>>m>>c;
	int b[m],a[n][m];
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	int d,e=0;
	for(int i=0;i<n;i++){
		d=0;
		for(int j=0;j<m;j++){
			d+=a[i][j]*b[j];
		}
		d+=c;
		if(d>0){
			e++;
		}
	}
	cout<<e<<endl;
	return 0;
}

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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

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

  string A, B, C;
  cin >> A >> B >> C;

  if((A[A.length()-1] == B[0]) && (B[B.length()-1] == C[0])) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

typedef long long ll;

ll a, v, b, w, t;

int main() {
	cin>>a>>v>>b>>w>>t;
  if(a-t*v<=b-t*w && b+t*w<=a+t*v) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc052/tasks/abc052_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, c, d, s;

  cin >> a >> b >> c >> d;

  s = a * b < c * d ? c * d : a * b;

  cout << s << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    s = '?' + s + '?';
    char t[Q], d[Q];
    rep(i, Q){
        cin >> t[i] >> d[i];
    }
    //lより左とrより右が最終的にはけられる
    int l = 0, r = N+1;
    rep3(i, Q-1, 0){
        if(t[i] == s[l+1] && d[i] == 'L') l++;
        elif(t[i] == s[l] && d[i] == 'R') l--;
        if(t[i] == s[r-1] && d[i] == 'R') r--;
        elif(t[i] == s[r] && d[i] == 'L') r++;
    }
    cout << r-l-1 << endl;
}

Measured memory_bytes: 1088
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

ll oddsolve(ll a) { return (a + 1) / 2 % 2; }
ll solve(ll a) {
	if (a % 2 == 1) return oddsolve(a);
	else return oddsolve(a + 1) ^ (a + 1);
}

int main() {
	ll a, b; cin >> a >> b;

	cout << (solve(b) ^ solve(a - 1)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define pii              pair <int,int>
#define debug(x) cerr << '>' << #x << ':' << x << endl;
//#pragma comment(linker, "/STACK:667772160")
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e18+99;
const int MOD=1e9+7;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
void boostIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int32_t main(){
    boostIO();
    int n;
    cin>>n;

    vi in(n);
    REP(i,n)
    cin>>in[i];

    int ans=0;
    REP(i,n){
        

        while(in[i]%2==0)in[i]/=2,ans++;
    }
    cout<<ans<<endl;





}


Measured memory_bytes: 384
function Main(input) {
    const lines = input.split("\n");

    const [A, B, M] = lines.shift().split(' ').map(Number);
    const aList = lines.shift().split(' ').map(Number);
    const bList = lines.shift().split(' ').map(Number);

    const minA = Math.min(...aList);
    const minB = Math.min(...bList);

    let minCost = minA + minB;

    for (let i = 0; i < M; i++) {
        const [x, y, c] = lines[i].split(' ').map(Number);
        minCost = Math.min(minCost, aList[x-1] + bList[y-1] - c);
    }

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------


int main(){
    int N=IN_int();
    vi p(N);
    rep(i,N) p[i]=IN_int();
    int count=0;
    rep(i,N) if(p[i]!=i+1) count++;
    printf(count<=2?"YES":"NO");
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define ld long double
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int mod = 1e9+7;
const int mod1 = 998244353;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int, int>&i, const pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

set<ll> oddfac(ll n) {
   set<ll> s;
   if(n%2) s.insert(n);
   for(ll i = 2; i <= sqrt(n); i++) {
      if(n % i == 0) {
         if(i%2) {
            s.insert(i);
         }
         if(n/i % 2) {
            s.insert(n/i);
         }
      }
   }
   return s;
}

void test() {
   int x[6];
   for(int i = 1; i <= 5; i++) {
      cin >> x[i];
      if(!x[i]) {
         cout << i;
         break;
      }
   }
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   faster;
   cout.precision(10);
   cout << fixed;

   int t = 1;
   //cin >> t;
   while(t--)
      test();

   return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

int h[100005];

void solve(){
	int n;
	cin>>n;
	rep(i,0,n){
		cin>>h[i];
	}
	int a,b=abs(h[n-1]-h[n-2]),c=0;
	a=b;
	for(int i=n-3;i>=0;i--){
		a=min(abs(h[i]-h[i+1])+b,abs(h[i]-h[i+2])+c);
		c=b;
		b=a;
	}
	cout<<b<<"\n";
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder output = new StringBuilder();
		int r = scan.nextInt();
		int c = scan.nextInt();
		int[][] sheet = new int[r+1][c+1];
		
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sheet[i][j] = scan.nextInt();
			}
		}
		
		// 表の端に合計を記録
		int sum_r = 0;
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sum_r += sheet[i][j];
			}
			sheet[i][c] = sum_r;
			sum_r = 0;
		}
		int sum_c = 0;
		for (int j = 0; j < c; j++) {
			for (int i = 0; i < r; i++) {
				sum_c += sheet[i][j];
			}
			sheet[r][j] = sum_c;
			sum_c = 0;
		}
		int sum_all = 0;
		for (int i = 0; i < r; i++) {
			sum_all += sheet[i][c];
		}
		sheet[r][c] = sum_all;
		
		// 出力
		for (int i = 0; i < r+1; i++) {
			output.append(sheet[i][0]);
			for (int j = 1; j < c+1; j++) {
				output.append(" ").append(sheet[i][j]);
			}
			output.append('\n');
		}
		System.out.print(output);
		scan.close();
	}
}

Measured memory_bytes: 34928
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 2E5;
struct Node {
    int p, x, y;
    Node(int p, int x, int y) : p(p), x(x), y(y) {}
};
bool operator<(const Node &lhs, const Node &rhs) {return 1LL * lhs.x * rhs.y < 1LL * lhs.y * rhs.x;}
int n;
int parent[N], v[N], fa[N], x[N], y[N];
LL ans;
int find(int x) {
    while (fa[x] >= 0 && fa[fa[x]] >= 0)
        x = fa[x] = fa[fa[x]];
    return fa[x] >= 0 ? fa[x] : x;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    memset(fa, -1, n * sizeof(int));
    for (int i = 1; i < n; ++i) {
        cin >> parent[i];
        --parent[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        (v[i] == 0 ? x[i] : y[i]) = 1;
    }
    priority_queue<Node> h;
    for (int i = 1; i < n; ++i)
        h.emplace(i, x[i], y[i]);
    while (!h.empty()) {
        auto u = h.top();
        h.pop();
        int p = u.p;
        if (u.x != x[p] || u.y != y[p])
            continue;
        int pa = find(parent[p]);
        ans += 1LL * y[pa] * x[p];
        x[pa] += x[p];
        y[pa] += y[p];
        fa[p] = pa;
        if (pa != 0)
            h.emplace(pa, x[pa], y[pa]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8692
#include<iostream>
using namespace std;
bool m[110][110];
int main()
{
    int n,u,k,v;
    cin>>n;
    for(int j=1;j<=n;j++)
    {
        cin>>u>>k;
        for(int i=1;i<=k;i++)
        {
            cin>>v;
            m[u][v]=1; //连边
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j!=1) cout<<" ";
            cout<<m[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 string S,T;
 cin >> S >> T;
  bool a=true;
  for(int i=0;i<S.size();i++){
   if(S.at(i)!=T.at(i)){
    a=false;
    break;
   }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int n,ans[100005],m;
vector <pair<int,int> > v[100005];
bool yes=true;
void dfs (int x,int cur,bool s)
{
    if (ans[x]&&!s)
    {
        if (ans[x]!=cur)
            yes=false;
        return;
    }
    ans[x]=cur;
    for (int i=0;i<v[x].size();i++)
        dfs(v[x][i].first,cur+v[x][i].second,0);
}
int main()
{
    cin >>n>>m;
    for (int i=0;i<m;i++)
    {
        int l,r,d;
        cin >>l>>r>>d;
        v[l].push_back({r,d});
        v[r].push_back({l,-d});
    }
    for (int i=1;i<=n;i++)
    {
        if (!ans[i])
        {
            ans[i]=1e9+1;
            dfs(i,1e9+1,1);
        }
    }
    yes?cout<<"Yes":cout<<"No";
    return 0;
}


Measured memory_bytes: 12032
N = int(input())
a = 0
b = 0
c = 0
d = 0
for n in range(N):
    s = input()
    if s == 'AC':
        a += 1
    if s == 'WA':
        b += 1
    if s == 'TLE':
        c += 1
    if s == 'RE':
        d += 1

print('AC x ' + str(a))
print('WA x ' + str(b))
print('TLE x ' + str(c))
print('RE x ' + str(d))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, k, a[MAX_N], b[MAX_N];

// ll xor(ll x, ll y){
// 	if(x == y) return 1LL;
// 	else return 0LL;
// }

signed main(){
	cin >> n >> k;
	REP(i, n){ cin >> a[i]; b[i] = a[i]; }
	ll ret = 0;
	ll tmp[45][2];
	REP(i, 45) REP(j, 2) tmp[i][j] = 0;
	REP(i, 45){
		REP(bit, 2){
			REP(j, n){
				// cout << a[j] << "xor" << bit << '=' << (a[j]^bit) << ' ' << ((a[j] ^ bit) & (1LL)) << endl;
				tmp[i][bit] += ((a[j] >> i) ^ bit) & (1LL);
			}
		}
		// REP(j, n) a[j] /= 2;
		// cout << tmp[i][0] << ' ' << tmp[i][1] << endl;
	}
	for(ll i=44; i>=0; i--){
	// for(ll i=0; i<45; i++){
		if(tmp[i][0] < tmp[i][1] && (ret | (1LL << i)) <= k)
			ret |= 1LL << i;
	}
	// cout << ret << endl;
	ll ans = 0;
	REP(i, n) ans += ret ^ b[i];
	cout << ans << endl;
    return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	ll n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;
	ll r = min(min(min(min(d,e),c),b),a);
	if(n == r)cout << 5 << endl;
	else if((n + r) % r == 0)cout << (n + r) / r + 3 << endl;
	else cout << (n + r) / r + 4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll d = 0;
  cin >> d;
  vector<ll> c(26);
  //ll min = 0;
  //min = pow(10,18);
  //ll mini = 0;
  for(int i = 0;i < 26;i++){
    cin >> c[i];
    //if(min > c[i])min = c[i],mini = i;
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  vector<ll> last(26);
  for(int i = 0;i < 26;i++)last[i] = -1;
  for(int i = 0;i < d;i++){
    ll now = 0;
    ll nowi = 0;
    for(int j = 0;j < 26;j++){
      cin >> s[i][j];
      s[i][j] += c[j] * (i - last[j]) * (d - i + 1);
      if(now < s[i][j]){
        now = s[i][j];
        nowi = j;
      }
    }
    last[nowi] = i;
    cout << nowi + 1 << endl;
  }
  //for(int i = 0;i < 365;i++)cout << mini + 1 << endl;
}



Measured memory_bytes: 3280
#include<stdio.h>
#include<stdlib.h>
void InsertSort(int *a,int n){
    int i,j,v,k;

    for (k = 0; k <n; k++) {
        if (k==n-1) {
            printf("%d\n",a[k]);
        }
        else printf("%d ",a[k]);
    }


    for (i = 1; i < n; i++) {
        v=a[i];
        j=i-1;
        while (j!=-1&&a[j]>v) {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for (k = 0; k <n; k++) {
            if (k==n-1) {
                printf("%d\n",a[k]);
            }
            else printf("%d ",a[k]);
        }
    }

}


int main(int argc, char const *argv[]) {
    int *a,i,N;
    scanf("%d",&N);
    a=malloc(N*sizeof(int));
    for (i = 0; i < N; i++) {
    scanf("%d",&a[i]);
    }
    InsertSort(a,N);
    return 0;
}

Measured memory_bytes: 600
N=int(input())
A=list(map(int, input().split()))
arai=sum(A)
ans=10**19
sunuke=0
for a in range(N-1):
  sunuke+=A[a]
  arai-=A[a]
  if ans>abs(arai-sunuke):
    ans=abs(arai-sunuke)
print(ans)


Measured memory_bytes: 30600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanIntNum()
	fmt.Println(check(input))
}

// example
func check(num int) (result int) {
	return num * num
}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(c>= a && c<=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


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

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    string s;
    cin>>s;
    for(ll i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]){
            cout<<"Yes"<<endl;
            exit(0);
        }
    }
    cout<<"No"<<endl;
        
}

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

int main(){
	int n, x, i, j, k;

	while(1){
		int c = 0;
		cin>>n>>x;
		if(n == 0 && x == 0) break;
		
		for(i = 1; i <= n; i++){
			for(j = i + 1; j <= n; j++){
				for(k = j + 1; k <= n; k++){
					if(i + j + k != x) continue;
					c++;
				}
			}
				
		}
		
		cout<<c<<endl;

	}
	return 0;
}


Measured memory_bytes: 3124
var lines = []; var f;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {

    /* --TLE-- */

    var N = Number(lines[0].split(" ")[0]);
    var X = Number(lines[0].split(" ")[1]);

    var result = 0;

    // バーガーの厚さの数列
    // an+1 = 2an + 3
    // (an+1 + 3) = 2(an +3)
    // 2(an + 3) = 2^n(a1 + 3)
    // an =  2^(n+2) - 3

    // パティの量
    // bn+1 = 2bn + 1
    // bn+1 + 1 = 2(bn + 1)
    // 2(bn + 1) = 2^n(b1 + 1)
    // bn = 2^(n+1) - 1

    console.log(dfs(N, X));
});

// 第nバーガー， 第x層までルンルンが食べる
function dfs(n, x) {
    var len = Math.pow(2, n + 1) - 3; // バーガーの厚さ
    var num = Math.pow(2, n) - 1; // パティの厚さ

    if (n === 0) { return (1); } // 0段バーガーのパティは1枚

    if (x === 1) { return (0); } // ルンルンが1層しか食べない場合，それはパン
    else if (x <= len + 1) { return (dfs(n - 1, x - 1)) } // ルンルンが食べるハンバーガーが半分以下ならば
    else if (x == len + 2) { return (num + 1) }// ルンルンが食べるハンバーガーがちょうど半分
    else if (x <= (len + 1) * 2) { return (num + 1 + dfs(n - 1, x - len - 2)); }　// ルンルンが食べるハンバーガーが半分以上全部未満
    else { return (num * 2 + 1) }// ルンルンがハンバーガーを全部食べる
    
    // dfsの引数にx-1を渡すのは，最下層がパンであるため
}

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

const int N=200200,inf=0x3f3f3f3f;

int k;

struct edge
{
	int from,to,w,nextt;
}g[N];
int head[N],cnt=0;
void add(int u,int v,int w)
{
	cnt++;g[cnt].nextt=head[u];head[u]=cnt;g[cnt].to=v;g[cnt].from=u;g[cnt].w=w;
}

int dist[N],inq[N];queue<int> q;
void spfa()
{
	memset(dist,0x3f,sizeof dist);
	dist[1]=0;inq[1]=1;q.push(1);
	while (!q.empty())
	{
		int u=q.front();inq[u]=0;q.pop();
		for (int i=head[u];i;i=g[i].nextt)
		{
			int v=g[i].to,w=g[i].w;
			if (dist[v]>dist[u]+w)
			{
				dist[v]=dist[u]+w;
				if (!inq[v]){inq[v]=1;q.push(v);}
			}
		}
			
	}
}


int main()
{
	cin>>k;
	for (int i=0;i<k;i++) add(i,(i+1)%k,1);
	for (int i=1;i<k;i++) add(i,i*10%k,0);
	spfa();
	cout<<dist[0]+1;
	return 0;
}

Measured memory_bytes: 5376
a,b = map(int,raw_input().split())
valid = True
s = raw_input()
for ind in range(len(s)):
        if ind == a:
            if s[ind] != "-":
                valid = False
        else:
            if s[ind].isalpha() or s[ind] == "-":
                valid = False        
if valid: print "Yes"
else: print "No"

Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

struct E{int from,to,cost;};

int N,n,d[200];
char c;
string s,s2;
E e[200];

int main(){
	while(cin>>N){
		if(!N)return 0;
		set<string> sts;
		map<string,int> tab;
		for(int i=0;i<N;i++){
			cin>>n>>s>>c>>n>>c>>n>>s2;
			if(sts.find(s)==sts.end()){
				tab[s]=sts.size();
				sts.insert(s);
			}
			if(sts.find(s2)==sts.end()){
				tab[s2]=sts.size();
				sts.insert(s2);
			}
			e[i*2].from=tab[s];
			e[i*2].to=tab[s2];
			e[i*2].cost=n;
			e[i*2+1].from=tab[s2];
			e[i*2+1].to=tab[s];
			e[i*2+1].cost=-1*n;
		}
		fill(d,d+sts.size(),0);
		bool f=0;
		for(int i=0;i<sts.size();i++){
			for(int j=0;j<2*N;j++){
				if(d[e[j].to]>d[e[j].from]+e[j].cost){
					d[e[j].to]=d[e[j].from]+e[j].cost;
					if(i==sts.size()-1){f=1;break;}
				}
			}
		}
		if(f)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 0
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    # print(N, A, B)
    expected = sum(B) - sum(A)
    if expected < 0:
        print('No')
        return
    add_a, add_b = 0, 0
    for i in range(N):
        a, b = A[i], B[i]
        if a > b:
            add_b += a - b
        elif a < b:
            add_a += (b - a + 1) // 2
    if add_a <= expected and add_b <= expected:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include <iostream>
using namespace std;
int n,x,d;
void fun(int a)
{
	int i=1;
	while(i<=d)
	{
		i+=a;
		x++;
	}
}

int main() {
	int p;
	cin>>n>>d>>x;
	for(int i=0;i<n;i++)
	{
		cin>>p;
		fun(p);
	}
	cout<<x<<'\n';
	return 0;
}




Measured memory_bytes: 256
// https://atcoder.jp/contests/arc097/tasks/arc097_b
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, t, u, cnt = 0;
    cin >> n >> m;
    vector<int> p(n);
    REP(i, n) {
        cin >> t;
        p[i] = t - 1;
    }

    UnionFind tree(n);
    REP(i, m) {
        cin >> t >> u;
        t--, u--;
        tree.unite(t, u);
    }

    REP(i, n) {
        // is_reachableを呼び出すと第3引数が更新されるので、毎回初期化する
        if (i == p[i] || tree.same(i, p[i])) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
    long long int N;
    string al[26]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    cin>>N;
    int tmp;
    string sum="";
    for(int i=1;i<99;i++){
        if(N<=pow(26,i)){
            N-=1;
    for(int j=0;j<i;j++){
        tmp=N%26;
        sum+=al[tmp];
        N/=26;
    }
    break;
        }
        else{
            N-=pow(26,i);
        }
    }
    reverse(sum.begin(),sum.end());
    cout <<sum;
    return 0;
}

Measured memory_bytes: 4108
#include <iostream>
#include <bits/stdc++.h>
// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
map<string, int> freq;

int main()
{
    int n;
    char last;
    bool possible = true;
    string s;
    cin>>n;
    forall(i,0,n){
        cin>>s;
        if (i){
           if (freq.count(s)){
                possible = 0;
           }
           if (s[0] != last){
                possible = 0;
           }
        }
        freq[s]++;
        last = s[s.length() - 1];
    }
    if (possible){
        cout<<"Yes";
    } else {
        cout<<"No";
    }
    return 0;
}


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

using namespace std;

#define pb push_back
#define prr pair<int,int> 
#define int long long
#define fir first
#define sec second
#define double long double
#define ll long long



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,n;
    cin>>a>>b>>n;
    if(n>=b){
        int x=b-1;
        int a1=(a*x)/b;
        int a2=x/b;
        a2=a2*a;
        int diff=a1-a2;
        cout<<diff;
    }else{
        int x=n;
        int a1=(a*x)/b;
        int a2=x/b;
        a2=a2*a;
        int diff=a1-a2;
        cout<<diff;

    }
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    set<int>st;
    st.insert(a);
    st.insert(b);
    if(!st.count(1)) cout<<1<<endl;
    if(!st.count(2)) cout<<2<<endl;
    if(!st.count(3)) cout<<3<<endl;
    return 0;
}


Measured memory_bytes: 256
x = int(input())

res = 0
if(400 <= x <= 599): res = 8
if(600 <= x <= 799): res = 7
if(800 <= x <= 999): res = 6
if(1000 <= x <= 1199): res = 5
if(1200 <= x <= 1399): res = 4
if(1400 <= x <= 1599): res = 3
if(1600 <= x <= 1799): res = 2
if(1800 <= x <= 1999): res = 1

print(res)

Measured memory_bytes: 9204
from collections import Counter

n, k, q = map(int,input().split())
winner = [int(input()) -1 for i in range(q)]
mycount = Counter(winner)
point = [k - (q - mycount[i])for i in range(n)]

for i in range(n):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15064
# import sys
# import math #sqrt
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # deque
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n = int(input())
    ans = 0
    for i in range(n):
        l,r = map(int,input().split())
        ans += r - l + 1
    print(ans)
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 3952
function Main(input) {
  const S = input.trim();

  let answer = "0";

  switch (S) {
    case "RSR":
    case "RSS":
    case "SRS":
    case "SSR":
      answer = "1";
      break;
    case "RRS":
    case "SRR":
      answer = "2";
      break;
    case "RRR":
      answer = "3";
      break;
  }
  
  console.log(answer);

}
// デバッグ用
function debug(){
var input = document.getElementById("input").value;
Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29504