akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	a := make([]int, N + 1)
	a[N] = -1145141919
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a[i])
	}
	ret, f := [...]uint64{0, 0}, [...]bool{true, true}
	s, sl := [...]int{0, 1}, [...]int{1 - N % 2, N % 2}
	maxmini := N
	for j := 0; j < 2; j++ {
		for i := 0; i < N / 2 + N % 2 * (1 - j); i++ {
			if a[2 * i + j] >= 0 {
				ret[j] += uint64(a[2 * i + j])
				if f[j] {
					f[j] = false
				}
			} else if f[j] {
				s[j] += 2
				if a[2 * i + j] > a[maxmini] {
					maxmini = 2 * i + j
				}
			}
		}
		for i := N / 2 + N % 2 * (1 - j) - 1; i >= 0 && a[2 * i + j] < 0; i-- {
			sl[j] += 2
		}
	}
	if f[0] && f[1] {
		fmt.Printf("%d\n", a[maxmini])
		fmt.Printf("%d\n", N - 1)
		for i := 0; i < N - 1 - maxmini; i++ {
			fmt.Printf("%d\n", N - i)
		}
		for i := 0; i < maxmini; i++ {
			fmt.Printf("1\n")
		}
		return
	}
	best := 0
	if ret[0] < ret[1] {
		best = 1
	}
	fmt.Printf("%d\n", ret[best])
	fmt.Printf("%d\n", sl[best] + s[best] + (N - sl[best] - s[best] - 1) / 2)
	for i := 0; i < sl[best]; i++ {
		fmt.Printf("%d\n", N - i)
	}
	for i := 0; i < s[best]; i++ {
		fmt.Printf("1\n")
	}
	for i := 0; i < (N - sl[best] - s[best] - 1) / 2; i++ {
		if a[s[best] + 2 * i + 2] >= 0 {
			fmt.Printf("2\n")
		} else {
			fmt.Printf("3\n")
		}
	}
	return
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) { 
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll nCr(ll n, ll r, ll mod) 
{
    ll x = 1, y = 1;
    
    lrep(i, r) {
        x *= n-i;
        x %= mod;

        y *= i+1;
        y %= mod;
    }

    ll rtn = (x * modinv(y, mod)) % mod;
    return rtn;
}

int main(void)
{
    ll n, m;
    cin >> n >> m;

    cout << nCr(n,2, IMOD) + nCr(m,2, IMOD)<< endl;
}
/** atcoder **/


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int cnt = 0;
		for(int i=1;i<=N;i++){
			if(i.ToString().Length % 2 == 1) cnt++;
		}
		Console.WriteLine(cnt);
	}
	int N;
	public Sol(){
		N = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int type(const char *str)
{
	if (strcmp(str, "A") == 0) return 0;
	if (strcmp(str, "B") == 0) return 1;
	if (strcmp(str, "AB") == 0) return 2;
	return 3;
}
int main()
{
	int n, c[4]={0};
	char str[10];
	while (scanf("%d,%s\n", &n, str)>0) {
		c[type(str)] ++;
	}
	for (n = 0; n < 4; n ++)
		printf("%d\n", c[n]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, K, M;

void recurse(int n, int t){
	if(t >= N){
		if(n < M) M = n;
	}else{
		recurse(n * 2, t + 1);
		recurse(n + K, t + 1);
	}
}

int main(void){
	//IO("test.in", "test.out");
	M = INT_MAX;
	scanf("%d%d", &N, &K);
	recurse(1, 0);
	printf("%d\n", M);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N;

int main() {
	cin >> N;
	cout << N * (N + 1) / 2 << endl;
		return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,k;
    cin>>n>>k;
    V vec(n);
    rep(i,n)cin>>vec[i];
    sort(all(vec));
    ll res=0;
    rep(i,k)res+=vec[i];
    cout<<res<<endl;
}


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

using i64 = int64_t;

int main() {
    int w,a,b;
    cin >> w >> a >> b;
    if (a < b) {
        if(a+w >= b) { cout << 0 << endl; }
        else {cout << b - (a+w)  << endl;}
    } else if (b < a){
        if(b+w >= a) { cout << 0 << endl; }
        else {cout << a - (b+w) << endl;}
    } else {
        cout << 0 << endl;
    }

}


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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define ll      long long

int x[202020];
int l[202020][20], r[202020][20];
int dpl[1 << 20], dpr[1 << 20];

void solve() {
        int n, v;
        cin >> n >> v;
        for (int i = 0; i < n; i ++) cin >> x[i];
        int p;
        for (int i = 0; ; i ++) if ((1 << i) > v) {
                p = i + 1;
                break;
        }
        for (int i = 0; i < n; i ++) {
                int vv = v;
                for (int j = 0; j < p; j ++) {
                        if (i == 0 || x[i] - x[i - 1] > vv) l[i][j] = i;
                        else l[i][j] = l[i - 1][j];
                        vv /= 2;
                }    
        }
        for (int i = n - 1; i >= 0; i --) {
                int vv = v;
                for (int j = 0; j < p; j ++) {
                        if (i == n - 1 || x[i + 1] - x[i] > vv) r[i][j] = i;
                        else r[i][j] = r[i + 1][j];
                        vv /= 2;
                }
        }
        for (int i = 0; i < (1 << p); i ++) {
                if (i & 1) continue;
                for (int j = 1; j < p; j ++) {
                        if ((i >> j) & 1) continue;
                        if (dpr[i] == n) dpr[i | (1 << j)] = n;
                        else dpr[i | (1 << j)] = max(dpr[i | (1 << j)], r[dpr[i]][j] + 1);
                }
        }
        for (int i = 0; i < (1 << p); i ++) dpl[i] = n - 1;
        for (int i = 0; i < (1 << p); i ++) {
                if (i & 1) continue;
                for (int j = 1; j < p; j ++) {
                        if ((i >> j) & 1) continue;
                        if (dpl[i] == -1) dpl[i | (1 << j)] = -1;
                        else dpl[i | (1 << j)] = min(dpl[i | (1 << j)], l[dpl[i]][j] - 1);
                }
        }
        bool ok = false;
        for (int i = 0; i < n; i ++) {
                if (l[i][0] == i) {
                        int c = 0;
                        for (int j = 0; j < (1 << p); j ++) {
                                c ++;
                                if (j & 1) continue;
                                if (i > 0 && dpr[j] < i) continue;
                                if (r[i][0] < n - 1 && dpl[(1 << p) - 2 - j] > r[i][0]) continue;
                                break;
                        }
                        if (c < (1 << p)) ok = true;
                        else ok = false;
                }
                if (ok) cout << "Possible" << endl;
                else cout << "Impossible" << endl;
        }
        return;
}

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

Measured memory_bytes: 42880
#include <bits/stdc++.h>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;

int main(){
    ll n ;
    cin >> n ;
    string s ;
    cin >> s ;
    ll ans = 0 ;
    ll tem = 0 ;
    rep(i,n){
        if(s[i] == 'I')tem++ ;
        else tem-- ;
        ans = max(ans,tem) ;
    }
    cout << ans << endl;
}

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

int main(void){
	int n,a,b,c; //ツ青板学,ツ英ツ古ェ,ツ債堕古ェ

	while(cin>>n && n){
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;

			double me = (a + b) / 2.0;
			double avg = (a + b + c) / 3.0;

			if(a==100 || b==100 || c==100 || me >= 90 || avg >= 80)
				cout<<"A\n";
			else if(avg >= 70 || avg >= 50 && (a >= 80 || b >= 80))
				cout<<"B\n";
			else
				cout<<"C\n";
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
     ll n,i=0;
     string s="";
     cin>>n;
     while(n>0)
     {
       ll r=n%26;
       if(r==0)
       {
         s+="z";
         n=(n/26)-1;
       }
       else
       {
          char c='a'+r-1;
         s+=c;
         n=n/26;
       }
     }
   reverse(s.begin(),s.end());
     cout<<s<<"\n";
     return 0;
}

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

int func(int M, int N)
{
    vector<int> res;
    int mx = 7368795, index = M, cnt = N;
    vector<bool> can(mx, false);
    while (cnt > 0)
    {
        if (can[index] == false)
        {
            can[index] = true;
            cnt--;
            for (int i = index; i < mx; i += index)
            {
                can[i] = true;
            }
        }
        index++;
    }
    int ans = 0;
    for (int i = M; i < mx; i++)
    {
        if (can[i] == false)
            return i;
    }
}

int M, N;

int main()
{
    while (cin >> M >> N)
    {
        if (M == 0 && N == 0)
            return 0;
        cout << func(M, N) << endl;
    }
}


Measured memory_bytes: 3984
import sys
input = sys.stdin.readline

def func(x,y):
    return min(x,y)

class LazySegmentTree():
    def __init__(self, n):
        self.lv = (n-1).bit_length()
        self.n = 2 ** self.lv
        self.arr = [2**31-1] * (2*self.n-1)
        self.lazy = [None] * (2*self.n-1)

    #伝播区間
    def getidx(self, l, r):
        L = (l + self.n) >> 1
        R = (r + self.n) >> 1
        lc = 0 if l & 1 else (L & -L).bit_length()
        rc = 0 if r & 1 else (R & -R).bit_length()
        for i in range(self.lv):
            if rc <= i:
                yield R
            if L < R and lc <= i:
                yield L
            L >>= 1; R >>=1

    #伝播
    def propagate(self,*ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            if v is None:
                continue
            self.lazy[2*i-1] = self.arr[2*i-1] = self.lazy[2*i] = self.arr[2*i] = v
            self.lazy[i-1] = None

    #[l, r] をxで更新
    def update(self,l,r,x):
        #[l, r)に変更
        r+=1
        *ids, = self.getidx(l,r)
        self.propagate(*ids)

        L = self.n + l; R = self.n + r
        while L < R:
            if R & 1:
                R -=1
                self.lazy[R-1] = self.arr[R-1] = x
            if L & 1:
                self.lazy[L-1] = self.arr[L-1] = x
                L += 1
            L >>= 1; R >>= 1

        for i in ids:
            self.arr[i-1] = func(self.arr[2*i-1], self.arr[2*i])

    #[l, r]のクエリに答える
    def query(self,l,r):
        #[l, r)に変更
        r+=1
        self.propagate(*self.getidx(l,r))
        L = self.n + l; R = self.n + r

        s = 2**31-1
        while L < R:
            if R & 1:
                R -=1
                s = func(s, self.arr[R-1])
            if L & 1:
                s = func(s, self.arr[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

def main():
    n, q = map(int, input().split())
    row = LazySegmentTree(n - 2)
    col = LazySegmentTree(n - 2)
    row.update(0, n - 3, n - 2)
    col.update(0, n - 3, n - 2)
    ans = (n - 2) ** 2
    for _ in range(q):
        que = list(map(int, input().split()))
        pos = que[1] - 2
        if que[0] == 1:
            num = row.query(pos, pos)
            ans -= num
            num2 = col.query(0, 0)
            
            if num2 > pos:
                col.update(0, num - 1, pos)
        else:
            num = col.query(pos, pos)
            ans -= num
            num2 = row.query(0, 0)
            if num2 > pos:
                row.update(0, num - 1, pos)
    print(ans)
        
main()

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

int main(){
    int N;
    std::cin >> N;
    
    std::vector< int > buka(N, 0);
    
    for(int i=0; i<N-1; i++){
        int tmp;
        std::cin >> tmp;
        buka[tmp - 1]++;
    }
    for(int i=0; i<N; i++){
        std::cout << buka[i] << std::endl;
    }
    
    return 0;
}



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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    cin >> S;
    do {
        S.pop_back();
        if(S.size() % 2) S.pop_back();
    } while(string(S.begin(), S.begin() + S.size() / 2) != string(S.begin() + S.size() / 2, S.end()));
    cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<long long, long long> 
#define vin(v,N) for(int i=0;i<N;i++) cin>>v.at(i)
#define pb push_back

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(ll x,ll N){
  ll ret=1;
  for(int i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<ll,ll> factor(ll p){
  ll p1=p;
  map<ll,ll>ret;
  for(ll i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  ll N,W;cin>>N>>W;
  vector<P>item(N);
  //firstがw,secondがv
  ll V=0;
  rep(i,N){
    cin>>item[i].first>>item[i].second;
    chmax(V,item[i].second);
  }
  //rep(i,N) cout<<item[i].first<<" "<<item[i].second<<endl;
  //cout<<endl;
  
  ll dp[110][100100];
  
  rep(i,110){
    rep(j,100100){
      dp[i][j]=mod*10;
    }
  }
  
  dp[0][0]=0;
  
  for(ll i=0;i<N;i++){
    for(ll v=0;v<=N*V;v++){
      //買う
      if(v-item[i].second>=0)
        chmin(dp[i+1][v],dp[i][v-item[i].second]+item[i].first);
      //買わない
      chmin(dp[i+1][v],dp[i][v]);
    }
  }
  
  ll res=0;
  
  rep(i,110){
    rep(j,100100){
      if(dp[i][j]<=W){
        chmax(res,j);
        //cout<<res<<endl;
      }
      //cout<<i<<" "<<j<<":"<<dp[i][j]<<endl;
    }
  }
  
  cout<<res;
}

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0;i < N;i++){
        cin >> vec.at(i) ;
    }
    
   int min = vec.at(0);
   for (int j =0;j < N;j++){
       if (min > vec.at(j)){
           min = vec.at(j);
       }
   }

   int max = 0;
   for (int h = 0;h < N;h++){
      if ((vec.at(h)-min)>max){
          max = vec.at(h)-min ;
      } 
   }
   
   cout << max <<endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
ls = [input().strip() for _ in range(h)]
counts = [[[-1] * w for _ in range(h)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        if ls[y][x] == '#':
            counts[0][y][x] = 0
        else:
            if x == 0:
                counts[0][y][x] = 1
            else:
                counts[0][y][x] = counts[0][y][x - 1] + 1
        yy = h - 1 - y
        xx = w - 1 - x
        if ls[yy][xx] == '#':
            counts[1][yy][xx] = 0
        else:
            if x == 0:
                counts[1][yy][xx] = 1
            else:
                counts[1][yy][xx] = counts[1][yy][xx + 1] + 1

        if ls[y][x] == '#':
            counts[2][y][x] = 0
        else:
            if y == 0:
                counts[2][y][x] = 1
            else:
                counts[2][y][x] = counts[2][y - 1][x] + 1
        yy = h - 1 - y
        xx = w - 1 - x
        if ls[yy][xx] == '#':
            counts[3][yy][xx] = 0
        else:
            if y == 0:
                counts[3][yy][xx] = 1
            else:
                counts[3][yy][xx] = counts[3][yy + 1][xx] + 1

res = 0
for y in range(h):
    for x in range(w):
        val = -3
        for i in range(4):
            val += counts[i][y][x]
        res = max(res, val)

print(res)

Measured memory_bytes: 184152
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int M=2e5+5;
const ll INF=1e12;
ll a[M],f[M];
ll n;ll k;
int check(ll x)
{
    ll cost=0;
    for(int i=1;i<=n;i++)cost+=max(a[i]-x/f[i],0LL);
    if(cost<=k)return 1;return 0;
}
inline ll read()
{
    ll x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
int main()
{
    n=read(),k=read();
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<=n;i++) f[i]=read();
    sort(a+1,a+n+1); sort(f+1,f+n+1);
    reverse(f+1,f+n+1);
    ll l=0,r=INF,ans=0;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(check(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
import math
while True:
    N=int(input())
    if N==0:
      exit()
    se=0
    L=list(map(int,input().split()))
    ave=sum(L)/N
    for i in range(N):
        se+=(L[i]-ave)*(L[i]-ave)
    ans=math.sqrt(se/N)
    print(round(ans,8))


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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n, k;
    cin >> n >> k;
    if(n >= 2 * k - 1){
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
 * */

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
	for (auto i = 0; i < N; ++i)
	{
		ll A;
		cin >> A;
		q.push({ A, 1 });
	}

	while (q.size() > 1)
	{
		auto p = q.top();
		q.pop();
		auto p2 = q.top();
		q.pop();
		if (p.first * 2 >= p2.first)
		{
			q.push({ p.first + p2.first, p.second + p2.second });
		}
		else
		{
			q.push({ p.first + p2.first, p2.second });
		}
	}

	cout << q.top().second << endl;

	return 0;
}

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((r*100+g*10+b) % 4 == 0) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

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

using namespace std;

int main(){
    long long h, attack, pow;
    attack = 1;
    pow = 1;
    cin >> h;
    while(h!=1){
        h /= 2;
        pow *= 2;
        attack += pow;
    }

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


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

const int vmax=10010;

int N,M;
vector<int> graph[vmax];

bool used[vmax];

void dfs(int v,vector<int>& order){
	used[v]=true;
	for(auto &u:graph[v]){
		if(!used[u])
			dfs(u,order);
	}
	order.push_back(v);
}

void topologicalSort(vector<int>& order) {
	rep(i,N) used[i]=false;
	rep(i,N)if(!used[i]) dfs(i,order);
	reverse(order.begin(),order.end());
}

int main(void){
	cin >> N >> M;
	rep(i,M){
		int a,b;
		cin >> a >> b;
		graph[a].push_back(b);
	}
	vector<int> order;
	topologicalSort(order);
	for(auto &v:order) cout << v << endl;
	return 0;
}

Measured memory_bytes: 1960
#include<bits/stdc++.h>
using namespace std;
bool cmp(string a, string b)
{
	return a < b;
}
int main()
{
	int a;
	cin >> a;
	string arr[a + 5];
	for(int i=0; i<a; i++)
	{
		cin >> arr[i];
		sort(arr[i].begin(), arr[i].end());
	}
	sort(arr, arr+a, cmp);
	long long count = 1, sum = 0;
	for(int i=1; i<a; i++)
	{
		if(arr[i] == arr[i-1]) count++;
		else
		{
			if(count > 1)
			{
				sum += (long long) (count * (count - 1)) / 2;
				count = 1;
			}
		}
		if(i == a - 1 && count > 1)
			sum += (long long) (count * (count - 1)) / 2;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
class dice{
public:
	int d1;
	int d2;
	int d3;
	int d4;
	int d5;
	int d6;
	int kaisi(int s1, int s2, int s3, int s4 ,int s5,int s6);
	int kakunin(int x,int y);
	//int miru(dice iti,dice ni);
};
int dice::kaisi(int s1,int s2,int s3,int s4,int s5,int s6){
  d1 = s1;
  d2 = s2;
  d3 = s3;
  d4 = s4;
  d5 = s5;
  d6 = s6;
}
 int miru(dice iti,dice ni){
	int a1,a2,a3,a4,a5,a6;
	int aho = 0;
	a1 = ni.d1;
	a2 = ni.d2;
	a3 = ni.d3;
	a4 = ni.d4;
	a5 = ni.d5;
	a6 = ni.d6;

	
	if(iti.d1 == ni.d2){
		//cout<<2<<endl;
		ni.d1 = a2;
		ni.d2 = a6;
		ni.d3 = a3;
		ni.d4 = a4;
		ni.d5 = a1;
		ni.d6 = a5;        
	}
	else if(iti.d1 == ni.d3){
		//cout<<3<<endl;
		ni.d1 = a3;
		ni.d2 = a2;
		ni.d3 = a6;
		ni.d4 = a1;
		ni.d5 = a5;
		ni.d6 = a4;
	}
	else if(iti.d1 == ni.d4){
		//cout<<4<<endl;
		ni.d1 = a4;
 		ni.d2 = a2;
		ni.d3 = a1;
		ni.d4 = a6;
		ni.d5 = a5;
		ni.d6 = a3;
	}
	else if(iti.d1 == ni.d5){
		//cout<<5<<endl;
		ni.d1 = a5;
		ni.d2 = a1;
		ni.d3 = a3;
		ni.d4 = a4;
		ni.d5 = a6;
		ni.d6 = a2;  
	}
	else if(iti.d1 == ni.d6){
		//cout<<6<<endl;
		ni.d1 = a6;
		ni.d2 = a5;
		ni.d3 = a3;     
		ni.d4 = a4;
		ni.d5 = a2; 
		ni.d6 = a1;
	}
	
    for(int i = 0;i< 4;i++){
    	int b;
    	b = ni.d4;
    	ni.d4 = ni.d2;
    	ni.d2 = ni.d3;
    	ni.d3 = ni.d5;
    	ni.d5 = b;
    	if(iti.d1 == ni.d1 && iti.d2 == ni.d2 && iti.d3 == ni.d3 && iti.d4 == ni.d4 && iti.d5 == ni.d5 && iti.d6 == ni.d6){
   			aho = 1;
    	}
    }
    for(int i = 0;i< 4;i++){
    	int b;
    	b = ni.d1;
    	ni.d1 = ni.d5;
    	ni.d5 = ni.d6;
    	ni.d6 = ni.d2;
    	ni.d2 = b;
    	if(iti.d1 == ni.d1 && iti.d2 == ni.d2 && iti.d3 == ni.d3 && iti.d4 == ni.d4 && iti.d5 == ni.d5 && iti.d6 == ni.d6){
   			aho = 1;
    	}
    }
    	//cout<<ni.d1<<ni.d2<<ni.d3<<ni.d4<<ni.d5<<ni.d6<<endl;
    
    if(aho == 1){
    	cout<<"Yes"<<endl;
    }else{
		cout<<"No"<<endl;
	}
	//cout<<ni.d1<<ni.d2<<ni.d3<<ni.d4<<ni.d5<<ni.d6<<endl;
}
int main(){
	int s1,s2,s3,s4,s5,s6,e1,e2,e3,e4,e5,e6;
	cin>>s1>>s2>>s3>>s4>>s5>>s6;
	cin>>e1>>e2>>e3>>e4>>e5>>e6;
	dice iti,ni;
	iti.kaisi(s1,s2,s3,s4,s5,s6);
	ni.kaisi(e1,e2,e3,e4,e5,e6);
	miru(iti,ni);
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

vull factorization(ull n){
  vull v;
  ull MAX=sqrt(n)+1;
  for(ull i=2;i<MAX;++i) while(n%i==0) {
      v.pb(i);
      n/=i;
  }
  if(n!=1) v.pb(n);
  return v;
}

void solve() {
  // main coding
  ull a,b;
  cin>>a>>b;
  ull g=gcd(a,b);
  vull v=factorization(g);
  v.erase(unique(v.begin(),v.end()),v.end());
  cout<<v.size()+1<<endl;
}

int main() {
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int cnt = 0, sum = 1;
    while (sum < b) {
        sum--;
        sum += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int m,f,b;
   cin >> m >> f >> b;
   if(m >= b){
       cout << 0 << endl;
   }
   else if(m+f >= b){
       cout << b-m << endl;
   }
   else{
       cout << "NA" << endl;
   }
}


Measured memory_bytes: 3104
#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)
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;
}


int n,m;
int ans = 0;
vector<vector<int>> g(8,vector<int>());
vector<bool> visited(8);

void dfs(int cur){
	bool ok = true;
	rep(i,n){
		if(!visited.at(i)) ok = false;
	}
	if(ok){
		ans++;
		return;
	}
	rep(i,g[cur].size()){
		int next = g[cur][i];
		if(!visited.at(next)){
			visited.at(next) = true;
			dfs(next);
			visited.at(next) = false;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	rep(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	visited.at(0) = true;
	dfs(0);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
using graph=vector<vector<int>>;
vector<bool> seen;

void dfs(int N,vector<int> &ans,vector<int> &plus,graph &G){
	seen[N]=true;
	for(auto i : G[N]){
		if(seen[i])continue;
		else{
			plus[i]+=plus[N];
			dfs(i,ans,plus,G);
		}
	}
}


int main() {
	int N,Q;
	cin>>N>>Q;
	graph G(N,vector<int>(0));
	
	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);
	}
	vector<int> plus(Q,0);
	for(int i=0;i<Q;i++){
		int p,x;
		cin>>p>>x; p--;
		plus[p]+=x;
	}
	
	seen.assign(N,false);
	seen[0]=true;
	vector<int> ans(N,0);
	dfs(0,ans,plus,G);
	
	for(int i=0;i<N;i++){
		cout<<plus[i]<<' ';
	}
	cout<<endl;
	
	return 0;
}

	

Measured memory_bytes: 30592
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc1 = new Scanner(System.in);
		int n = sc1.nextInt();
		String s = sc1.next();
		String[] sArray = s.split("");
		int ans = 0;
		int x = 0;
		for (int i = 0; i < n; i++) {
			if (sArray[i].equals("I")) {
				x = x + 1;
			} else {
				x = x - 1;
			}
			if (ans < x) {
				ans = x;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	unsigned long long int ans = 1;
	for (int i = 2; i <= N; ++i)
	{
		ans *= i;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

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

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

int main () {
    int N, M, tmp;
    cin >> N >> M;
    for (int i = 0; i < M; i ++){
        cin >> tmp;
        N -= tmp;
    }
    N = max(N, -1);
    cout << N << endl;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    //amax[i] : i-1番目以前の石の山の内，最大個数を格納．
    vector<ll> amax(n, 0);
    for(int i = 1; i < n; ++i) amax[i] = max(amax[i-1], a[i-1]);
    vector<P> ap(n);
    //同じ石の個数の場合は前の山が前にくるように設定．
    rep(i,n){
        ap[i].first = a[i];
        ap[i].second = -i;
    }
    //石の個数が大きい順にソート．
    sort(ap.rbegin(), ap.rend());
    int cnt = 0;
    vector<ll> ans(n, 0);
    for(int i = 0, j = 0; i < n; ){
        //idx : 今見ている山が元の位置で何番目か．
        int idx = -ap[i].second;
        ++cnt;
        ans[idx] += (a[idx] - amax[idx]) * cnt;
        j = i + 1;
        while(j < n){
            if(amax[idx] < ap[j].first){
                ans[idx] += (ap[j].first - amax[idx]);
                ++cnt;
                ++j;
            }
            else break;
        }
        i = j;
    }
    rep(i,n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll f(ll x) {
 ll res = 0;
 while (x % 2 == 0) {
   x /= 2;
   res++;
 }
 return res;
}
 
 
int main() {
 
 ll N, M;
 cin >> N >> M;
 
 ll a[N];
 for (int i = 0; i < N; i++) {
   cin >> a[i];
   a[i]/=2;
 }
 
ll t = f(a[0]);
 for (int i = 0; i < N; i++) {
   if (f(a[i]) != t) {
     cout << 0 << endl;
     return 0;
   }
   a[i] >>= t;
 }
 M >>= t;
 
 ll lcm_ = 1;
 for (int i = 0; i < N; i++) {
   lcm_ /=(__gcd(lcm_,a[i]));
   lcm_*=a[i];
   if (M < lcm_) {
     cout << 0 << endl;
     return 0;
   }
 }
 M/=lcm_;
 cout <<(M + 1)/2 << endl;
 
 return 0;
 
}

Measured memory_bytes: 1024
def solve(ln)
  op=ln.gsub(/[a-z]/,"").scan(/../)
  car=ln.split(/->|<-/)
  abort "Input strange in 'solve'" if  car.length != op.length + 1
  v = []
  i=0
  return [] if car.length==0
  v.push(car.shift)
  while op.length >0 do
    dir = op.shift
    abort ("car strange in solve") if car.length==0
    x = car.shift
    if dir == "->" then
      i += 1
    else
      i -= 1
    end
    if i == v.length then
      v.push(x)
    elsif i < 0 then
      v.unshift(x)
      i = 0
    elsif v[i] != x then
      abort("Something is strange")
    else
    #  puts("ok #{x}")
    end
  end

  return v.join
end

def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0130.txt")
  end
  n= fh.gets.chomp.to_i
  jyun = []
  0.upto(n-1){|i|
    ln = fh.gets.chomp
    jyun.push(ln)
  }

  0.upto(n-1){|i| puts solve(jyun[i])}
end

if $0 == __FILE__ then
  main
end

=begin
# test_sample.rb
require 'test/unit'
class TestSample < Test::Unit::TestCase
  def test_solve
    assert_equal solve("a->e->c->b->d"), "aecbd"
    assert_equal solve("b<-c<-a<-d<-e"), "edacb"
    assert_equal solve("b->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d"),"bacde"
    assert_equal solve("a->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c"), "bcdae"
  end
end
=end

Measured memory_bytes: 8940
n = list(input())
ans = []
op1 = ''
op2 = ''
op3 = ''
for i in range(8):
    lis = list(bin(i)[2:].zfill(3))
    temp = int(n[0])
    if lis[0] == '0':
        temp += int(n[1])
        op1 = '+'
    else:
        temp -= int(n[1])
        op1 = '-'
    if lis[1] == '0':
        temp += int(n[2])
        op2 = '+'
    else:
        temp -= int(n[2])
        op2 = '-'
    if lis[2] == '0':
        temp += int(n[3])
        op3 = '+'
    else:
        temp -= int(n[3])
        op3 = '-'
    if temp == 7:
        break
print('%s=7' % (n[0]+op1+n[1]+op2+n[2]+op3+n[3]))

Measured memory_bytes: 3064
import itertools

N,M = map(int,input().split())

card = [0] *N

for i in range(M):
    l, r = map(int,input().split())
    card[l-1] += 1
    if (r+1)-1 < N:
        card[r] -= 1
        
cumsum = list(itertools.accumulate(card))

print(cumsum.count(M))

Measured memory_bytes: 50776
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int INF = 1e9 + 239;

namespace Solver {
	int n;
	vector<int> a;
	multiset<int> vals;
	set<pair<int, int>> S;

	void init(int n_) {
		n = n_;
		a.resize(n);
		for (int i = 0; i < n; i++) {
			a[i] = 0;
			vals.insert(a[i]);
			S.insert({i, a[i]});
		}
	}

	void trim(int pos) {
		if (a[pos] == -1) {
			int pnt = prev(S.lower_bound({pos, -1}))->first;
			a[pos] = a[pnt] + (pos - pnt);
			vals.insert(a[pos]);
			S.insert({pos, a[pos]});
		}
	}

	int get(int pos) {
		trim(pos);
		return a[pos];
	}

	void set(int l, int r, int v) {
		if (l > 0) trim(l - 1);
		if (r + 1 < n) trim(r + 1);
		while (true) {
			auto it = S.lower_bound({l, -1});
			if (it == S.end() || it->first > r) {
				break;
			} else {
				vals.erase(vals.find(a[it->first]));
				a[it->first] = -1;
				S.erase(it);
			}
		}
		a[l] = v;
		vals.insert(a[l]);
		S.insert({l, a[l]});
	}

	int mn() {
		return *vals.begin();
	}
}

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

	int h, w;
	cin >> h >> w;
	Solver::init(w);
	vector<int> a(h);
	vector<int> b(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	for (int i = 1; i <= h; i++) {
		int val = INF;
		if (a[i - 1] - 1 >= 0) val = Solver::get(a[i - 1] - 1);
		Solver::set(a[i - 1], b[i - 1], val + 1);
		if (Solver::mn() >= INF) {
			cout << -1 << '\n';
		} else {
			cout << Solver::mn() + i << '\n';
		}
	}
}

Measured memory_bytes: 23936
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    ans=0
    for a in map(int,input().split()):
        ans+=1/a
    print(1/ans)
resolve()

Measured memory_bytes: 38256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    int N;
    int A,B;
    Scanner sc = new Scanner(System.in);
    
    N = sc.nextInt();
    
    if(N == 1){
      System.out.println("Hello World");
    }else if(N == 2){
      A = sc.nextInt();
      B = sc.nextInt();
      System.out.println(A + B);
    }
    sc.close();
    return;
  }
}
    
  

Measured memory_bytes: 23252
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := nextInt()
	t := make([]bool, 10000001)
	t[s] = true
	for i, now := 2, s; ; i++ {
		var next int
		if now%2 == 0 {
			next = now / 2
		} else {
			next = 3*now + 1
		}
		if t[next] {
			puts(i)
			break
		}
		t[next] = true
		now = next
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <bitset>

using namespace std;

void c()
{
    long long int n;
    cin >> n;
    vector<long long int> odd;
    vector<long long int> even;
    int p = 0;
    for (long long int i = 1; i <= 100000000000; i = i * 2) {
        if(p == 1)
        {
            even.push_back(i);
        }else{
            odd.push_back(i);
        }
        p = (p + 1) % 2;
    }
    ///半分全列挙
    map<long long int, int> oddmap;
    map<long long int, int> evenmap;
    for (unsigned long long int i = 0; i < pow(2, odd.size()); ++i) {
        unsigned long long int check = 1;
        long long int count = 0;
        int index = 0;
        for (;check <= i; check = check << 1) {
            if(i & check)
            {
                ///bitが立っている
                count += odd[index];
            }
            index++;
        }
        if(oddmap.count(count) == 0)
        {
            oddmap[count] = 1;
        }
    }
    for (unsigned long long int i = 0; i < pow(2, even.size()); ++i) {
        unsigned long long int check = 1;
        long long int count = 0;
        int index = 0;
        for (;check <= i; check = check << 1) {
            if(i & check)
            {
                ///bitが立っている
                count += even[index];
            }
            index++;
        }
        if(evenmap.count(count) == 0)
        {
            evenmap[count] = 1;
        }
    }
    long long int plus = 0, minus = 0;
    for (auto o : oddmap) {
        long long int nest = o.first - n;
        if(evenmap.count(nest) > 0)
        {
            plus = o.first;
            minus = nest;
        }
    }
    unsigned long long int result = plus + minus;
    string str = "";
    for (unsigned long long int check = 1; check <= result; check = check << 1) {
        if(check & result)
        {
            str.push_back('1');
        }else{
            str.push_back('0');
        }
    }
    reverse(str.begin(), str.end());
    if(str == "")
    {
        cout << "0" << endl;
    }else{
        cout << str << endl;
    }
}

int main() {
    typedef long long int ll;
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ///累積和を計算
    vector<ll> asum(n);
    asum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        asum[i] = asum[i - 1] + a[i];
    }
    ///Aj - Ai = cMはAjとAiがmod Mで合同を表す
    ll count = 0;
    map<ll, int> mod;
    for (int i = 0; i < n; ++i) {
        ll temp = asum[i] % m;
        if(mod.count(temp))
        {
            count += mod[temp];
            mod[temp]++;
        }else{
            mod[temp] = 1;
        }
        ///単体でMの倍数の箇所を数える
        if(temp == 0)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<queue<ll>> q(n);
    rep(i, n) {
        rep(j, n - 1) {
            ll a;
            cin >> a;
            a--;
            q[i].push(a);
        }
    }
    set<ll> s;
    queue<pair<ll, ll>> kh;
    rep(i, n) {
        if (s.count(i) > 0) continue;
        ll next = q[i].front();
        if (q[next].front() == i) {
            kh.push(make_pair(i, next));
            s.insert(i);
            s.insert(next);
        }
    }
    ll days = 0;
    while(!kh.empty()) {
        s.clear();
        queue<pair<ll, ll>> next;
        while(!kh.empty()) {
            pair<ll, ll> p = kh.front();
            kh.pop();
            if (sz(q[p.first]) > 0) {
                ll pfn = q[p.first].front();
                if ((q[pfn].front() == p.first) && (s.count(p.first) == 0) && (s.count(pfn) == 0)) {
                    q[p.first].pop();
                    q[pfn].pop();
                    next.push(make_pair(p.first, pfn));
                    s.insert(p.first);
                    s.insert(pfn);
                }
            }
            if (sz(q[p.second]) > 0) {
                ll psn = q[p.second].front();
                if ((q[psn].front() == p.second) && (s.count(p.second) == 0) && (s.count(psn) == 0)) {
                    q[p.second].pop();
                    q[psn].pop();
                    next.push(make_pair(p.second, psn));
                    s.insert(p.second);
                    s.insert(psn);
                }
            }
        }
        while(!next.empty()) {
            kh.push(next.front());
            next.pop();
        }
        days++;
    }
    ll remain = 0;
    rep(i, n) remain += sz(q[i]);
    if (remain > 0) {
        cout << -1 << endl;
    }
    else {
        cout << (days - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;

const int Inf = 10000*100000+100;
int a,b,V,E,R,S,Start[500000+10],To[500000+10],Dis[500000+10],N[500000+10];
int Ans[100000+10];

priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > Q;


int main() {
	cin >> V >> E >> R;
	for (int i=1; i<=E; i++){
		cin >> S >> To[i] >> Dis[i];
		N[i] = Start[S];
		Start[S] = i;
	}
	
	fill(Ans,Ans+100010,Inf);
	Ans[R] = 0;
	Q.push(make_pair(0,R));
	
	while(!Q.empty()){
		a = Q.top().first;
		b = Q.top().second;
		Q.pop();
		if (Ans[b] == a){
			for(int i=Start[b]; i; i=N[i]){
				int t = To[i];
				if (a+Dis[i] < Ans[t]){
					Ans[t] = a+Dis[i];
					Q.push(make_pair(Ans[t],t));
				}
			}
		}	
	}
	
	for (int i=0; i<V; i++){
		if (Ans[i] < Inf){
			cout << Ans[i] << endl;
		}else{
			cout << "INF" << endl;
		}
	}	
}

Measured memory_bytes: 10356
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
n=int(input())
A=[(e[0],int(e[2:]),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
print(s(A)+'table')
print("\n".join(f"{a} {b}"for a,b,_ in A))


Measured memory_bytes: 26988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}


int main(){
    
    make();
    
    int N;cin>>N;
    vector<int> A(N+1);
    map<int,int> M;
    for(int i=0;i<N+1;i++){
        cin>>A[i];
    }
    
    int left=-1,right=-1;
    
    for(int i=0;i<N+1;i++){
        if(M[A[i]]){
            left=M[A[i]]-1;
            right=i;
        }else M[A[i]]=i+1;
    }
    
    for(int i=1;i<=N+1;i++){
        if(i==1) cout<<N<<endl;
        else if(i==N){
            if(left+1==right) cout<<N<<endl;
            else cout<<N+1<<endl;
        }else if(i==N+1){
            cout<<1<<endl;
        }else{
            ll ans=0;
            ans+=comb(N-1,i);
            ans=(ans+comb(N-1,i-2))%mod;
            if(left+1==right){
                ans=(ans+comb(N-1,i-1))%mod;
                cout<<ans<<endl;
            }else{
                int diff=right-left-1;
                ans=(ans+comb(N-1,i-1)*2)%mod;
                ans=(ans+mod-comb(N-1-diff,i-1))%mod;
                cout<<ans<<endl;
            }
        }
    }
    
}


Measured memory_bytes: 8576