akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans[100] = {};
	for (int i = 1; i < n; i++) {
		int a[26] = {};
		int b[26] = {};
		for (int j = 0; j < i; j++) {
			for (int k = 0; k < 26; k++) {
				if (s[j] - 'a' == k) {
					a[k] = 1;
				}
			}
		}
		for (int j = i; j < n; j++) {
			for (int k = 0; k < 26; k++) {
				if (s[j] - 'a' == k) {
					b[k] = 1;
				}
			}
		}
		for (int j = 0; j < 26; j++) {
			if ((a[j] == 1) && (b[j] == 1)) {
				ans[i]++;
			}
		}
		//cout<<ans[i]<<endl;
	}
	sort(ans, ans + n);
	cout << ans[n-1] << endl;
}


Measured memory_bytes: 256
from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

div = 10**9+7

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

for i in range(1,K+1):
    if N-K+1 < i:
        print(0)
        continue
    ans = combinations_count(N-K+1,i) % div
    ans = ans * combinations_count(K-1,i-1) % div
    print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;

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

    long N = scanner.nextLong();
    int M = 1_000_000_007;

    int t = 0;
    long n = N;
    while (n > 0) {
      n /= 2;
      t++;
    }

    long[][] dp = new long[t + 1][3];
    dp[0][0] = 1;
    for (int i = 1; i <= t; i++) {
      if ((N >> (t - i)) % 2 == 0) {
        dp[i][0] = dp[i - 1][0];
        dp[i][0] = modAdd(dp[i][0], dp[i - 1][1], M);
        dp[i][1] = dp[i - 1][1];
        dp[i][2] = dp[i - 1][1];
        dp[i][2] = modAdd(dp[i][2], 3 * dp[i - 1][2] % M, M);
      } else {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = dp[i - 1][0];
        dp[i][1] = modAdd(dp[i][1], dp[i - 1][1], M);
        dp[i][2] = 2 * dp[i - 1][1] % M;
        dp[i][2] = modAdd(dp[i][2], 3 * dp[i - 1][2], M);
      }
    }

    long ans = 0;
    for (int i = 0; i < 3; i++) {
      ans += dp[t][i];
      ans %= M;
    }
    System.out.println(ans);
  }

  private static long modAdd(long a, long b, long M) {
    a += b % M;
    a %= M;
    return a;
  }
}


Measured memory_bytes: 23252
n = gets.chomp
print n + ":"
n = n.to_i
k = Math::sqrt(n)
k = k.to_i
for i in 2..k
  while n%i == 0
    print " #{i}"
    n = n/i
  end
end
if n != 1
  puts " #{n}"
else
puts ""
end

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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 1; i < S.size()/2; i++) {
		if(S.substr(0, i) == S.substr(i, i)) {
			ans = 2*i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b)
    for(int i=0;i<b;i++)
      cout<<a;
  else
    for(int i=0;i<a;i++)
      cout<<b;
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct yyy {
	long long x,y;
} ball[222222];
long long x[222222],y[222222],maxn[222222],minl[222222];
long long n,ans,ans1,ans2,bmax,bmin,rmax,rmin;
bool cmp(yyy a,yyy b) {
	return a.x<b.x;
}
int main() {
	cin>>n;
	bmax=rmax=-1;
	bmin=rmin=1999999999;
	for(int i=1; i<=n; ++i) {
		cin>>x[i]>>y[i];
		if(x[i]>y[i])
			swap(x[i],y[i]);
		ball[i].x=x[i];
		ball[i].y=y[i];
		bmax=max(bmax,y[i]);
		bmin=min(bmin,y[i]);
		rmax=max(rmax,x[i]);
		rmin=min(rmin,x[i]);
	}
	ans1=(bmax-bmin)*(rmax-rmin);
	bmin=rmin;
	sort(ball+1,ball+n+1,cmp);
	ans2=1999999999;
	maxn[1]=minl[1]=ball[1].y;
	for(int i=2; i<=n; ++i) {
		maxn[i]=max(maxn[i-1],ball[i].y);
		minl[i]=min(minl[i-1],ball[i].y);
		if(i!=n)
			ans2=min(ans2,max(maxn[i],ball[n].x)-min(minl[i],ball[i+1].x));
	}
	ans2*=(bmax-bmin);
	ans=min(ans1,ans2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
type uf_node = {
  mutable par: int;
  mutable rank: int;
}
;;

let uf_make n = Array.init n (fun i -> { par = i; rank = 0 })
;;

(* 根を求める *)
let rec uf_find uf x =
  if uf.(x).par == x
  then x
  else
    let par = uf.(x).par in
    let v = uf_find uf par in
    uf.(x).par <- v;
    v
;;

(* xとyの集合を併合 *)
let uf_unite uf x y =
  let x = uf_find uf x in
  let y = uf_find uf y in
  if x != y then
    if uf.(x).rank < uf.(y).rank
    then (
      uf.(x).par <- y;
      ()
    )
    else (
      uf.(y).par <- x;
      if uf.(x).rank == uf.(y).rank then (
        uf.(x).rank <- uf.(x).rank + 1;
        ()
      )
    )
;;

let uf_some uf x y = uf_find uf x == uf_find uf y
;;

let dec x = x -1
;;

let tuple2map fa fb (a, b) = (fa a, fb b)
;;

let tuple2 a b = (a, b)
;;

let curry2 f a b = f (a, b)
;;

let uncurry2 f (a, b) = f a b
;;

let (>>) f g x = g (f x)
;;

let (>>>) f g x y = g (f x y)
;;

let list_init n f = Array.init n f |> Array.to_list
;;

let () =
  let n, m = Scanf.scanf "%d %d\n" tuple2 in
  let p_list = list_init n (fun _ -> Scanf.scanf "%d " dec) in
  let xy_list = list_init m (fun _ -> Scanf.scanf "%d %d\n" (tuple2 >>> tuple2map dec dec)) in
  let uf = uf_make n in
  List.iter (uncurry2 @@ uf_unite uf) xy_list;
  let res = p_list |> List.mapi tuple2 |> List.filter (uncurry2 @@ uf_some uf) |> List.length in
  Printf.printf "%d\n" res
;;


Measured memory_bytes: 25216
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=chk=0
for i in range(n):
    ans+=b[a[i]-1]
    if i!=0 and a[i-1]+1==a[i]:
        ans+=c[a[i-1]-1]
print(ans)

Measured memory_bytes: 38256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    flg=false
    for h in 1:3500
        for w in h:3500
            res=n*h*w/(4*h*w-n*w-n*h)
            if res>0 && isinteger(res)
                println("$h $w $(Int(res))")
                flg=true
                break
            end
        end
        if flg
            break
        end
    end
end
main()

Measured memory_bytes: 166208
#include<stdio.h>
int main(){
  long long n,l,r,m;
  int i;
  scanf("%lld",&n);
  r=n;
  l=0;
  while(l-r){//printf("%lld %lld\n",l,r);
    m=(l+r)/2;
    if(m*(m+1)/2<n){
      l=m+1;
    }
    else{
      r=m;
    }
  }
  //printf("%lld\n",l);
  for(i=1;i<=l;i++){
    if(l*(l+1)/2==n+i)continue;
    printf("%d\n",i);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    string s;
    cin >> n >> s;

    ll r = 1;
    int l = 0;
    for (int i = 0; i < n * 2; i++) {
        if (s[i] == 'W' ^ i % 2 == 0) {
            l++;
        } else {
            if (l <= 0) {
                cout << 0 << endl;
                exit(0);
            }
            (r *= l) %= P;
            l--;
        }
    }

    if (l != 0) {
        cout << 0 << endl;
        exit(0);
    }

    for (int i = 0; i < n; i++) {
        (r *= i + 1) %= P;
    }

    cout << r << endl;

    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(m, vector<int>());
  vector<int> p(m);

  rep(i, m){
    int k;
    cin >> k;
    rep(j, k){
      int sw;
      cin >> sw;
      s[i].push_back(sw - 1);
    }
  }
  rep(i, m) cin >> p[i];

  int ans = 0;
  bool off;
  rep(i, (1 << n)){
    off = false;
    rep(j, m){
      int swcnt = 0;
      rep(l, s[j].size()){
        if ((i & (1 << s[j][l])) != 0) swcnt++;
      }
      if (swcnt % 2 != p[j]) off = true;
      if (off == true) break;
    }
    if (off == false) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m, x, y;
  cin >> n >> m >> x >> y; 
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> b(m);
  for (int i = 0; i < m; i++) 
    cin >> b[i];
  sort(begin(a), end(a));
  sort(begin(b), end(b));
  for (int z = x + 1; z <= y; z++) {
    if (z > a.back() && b[0] >= z) {
      cout << "No War\n";
      return 0;
    }
  }
  cout << "War\n";
  return 0;
}

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

void fnInput(int& rnMaxNum)
{
  cin >> rnMaxNum;
}

int64_t fnToInt(const vector<char>& cnrvcNum)
{
  const vector<int> cnvnDgt = {0, 3, 5, 7};
  int64_t nRtn = 0;
  int nNumPos = 0;

  for (int i = cnrvcNum.size() - 1; i >= 0; i--)
  {
    if (cnrvcNum[i] == '0') break;
    nRtn += cnvnDgt[ cnrvcNum[i] - '0' ] * pow(10.0, nNumPos++);
  }

  return nRtn;
}

int fnDgt753_Check(const vector<char>& cnrvcNum)
{
  int nDig3 = 0, nDig5 = 0, nDig7 = 0;

  for (int i = 0; i < cnrvcNum.size(); i++)
    if      (cnrvcNum[i] == '1') nDig3++;
    else if (cnrvcNum[i] == '2') nDig5++;
    else if (cnrvcNum[i] == '3') nDig7++;

  if (nDig3 && nDig5 && nDig7)
    return 1;
  else
    return 0;
}

int fnDgt753_Count(int nMaxNum)
{
  int nDgt753Cnt = 0;
  int nDgtSiz = to_string(nMaxNum).size();
  vector<char> vcNum(nDgtSiz + 1, '0');

  while (fnToInt(vcNum) <= nMaxNum) 
  {
    if (fnDgt753_Check(vcNum)) nDgt753Cnt++;

    vcNum[vcNum.size() - 1]++;
    for (int i = vcNum.size() - 1; i > 0; i--)
      if (vcNum[i] > '3')
      {  
        vcNum[i - 1]++;
        vcNum[i] = '1';
      }
      else
        break;
  }

  return nDgt753Cnt;
}

int main()
{
  int nMaxNum;

  fnInput(nMaxNum);
  cout << fnDgt753_Count(nMaxNum) << endl;

  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    int k; cin >> k;
    result = n*k;
    /*
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */

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

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,s;
    cin >> k >> s;
    int count = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int z = s - (i+j);
            if(0 <= z && z <= k) count++;
        }
    }
    cout << count << endl;
}

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

int main()
 {
 	int a,b,c,d,e;
 	cin>>a>>b>>c;
 	d=a-b;
 	if(d>=c)
 		cout<<"0"<<endl;
 	else
 		cout<<c-d<<endl;
 	 	
 	return 0;
}
 	
 					

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

const int N = 1e6 + 7;

int sz, a, b, n;
int res[N];

string tob(int x) {
	string s = "";
	while (x) {
		if (x % 2)
			s = '1' + s;
		else
			s = '0' + s;
		x /= 2;
	}
	while ((int)s.size() < sz)
		s = '0' + s;
	return s;
}
int dif(int x, int y) {
	string s = tob(x);
	string t = tob(y);
	int d = 0;
	for (int i = 0; i < sz; i++)
		if (s[i] != t[i])
			d++;
	return d;
}

void sml() {
	for (int i = 0; i < n; i++)
		res[i] = i;
	do {
		if (res[0] != a || res[n - 1] != b) 
			continue;
		bool ok = 1;
		for (int i = 0; i + 1 < n; i++)
			if (dif(res[i], res[i + 1]) > 1)
				ok = 0;
		if (ok) {
			cout << "YES" << '\n';
			for (int i = 0; i < n; i++)
				cout << res[i] << ' ';
			exit(0);
		}
	} while (next_permutation(res, res + n));
	cout << "NO";
	exit(0);
}
string f[N];
string g[N];
string ans[N];

string bes(string d, string e) {
	int pd = 0, pe = 0;
	string s = "";
	for (int i = 0; i < sz; i++)
		if ((b >> i) & 1)
			s = s + d[pd++];
		else
			s = s + e[pe++];
	return s;
}
int toi(string s) {
	int res = 0;
	for (int i = 0; i < s.size(); i++)
		if (s[i] == '1')
			res += (1 << i);
	return res;
}
bool mrk[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> sz >> a >> b;
	n = (1 << sz);
	if (sz <= 2)
		sml();
	if ((dif(a, b) % 2) == 0) {
		cout << "NO";
		return 0;
	}
	b = a ^ b;
	int sv = sz;
	int df = dif(0, b);
	sz = df - 2;
	for (int i = 0; i < (1 << df); i++) {
		if (i < ((1 << df) / 2))
			f[i] = "0";
		else
			f[i] = "1";
	}
	for (int j = 3; j <= df; j += 2) {
		for (int i = 0; i < (1 << df); i++) {
			int md = (i / (1 << (df - j))) % 8;
			if (md == 0) 
				f[i] += "00";
			if (md == 1)
				f[i] += "01";
			if (md == 2)
				f[i] += "11";
			if (md == 3)
				f[i] += "10";
			if ((i + 4 * (1 << (df - j)) < (1 << df))) {
				if (md == 4)
					f[i] += "10";
				if (md == 5)
					f[i] += "11";
				if (md == 6)
					f[i] += "01";
				if (md == 7)
					f[i] += "00";	
			}
			else {
				if (md == 4)
					f[i] += "10";
				if (md == 5)
					f[i] += "00";
				if (md == 6)
					f[i] += "01";
				if (md == 7)
					f[i] += "11";
			}
		}
	/*	for (int i = 0; i < (1 << df); i++)
			cout << f[i] << endl;
		cout << endl << endl << endl;*/
	}
	sz = sv;
	g[0] = "0";
	g[1] = "1";
	for (int j = 2; j <= sz - df; j++) {
		for (int i = (1 << (j - 1)); i < (1 << j); i++)
			g[i] = '1' + g[(1 << j) - i - 1];
		for (int i = 0; i < (1 << (j - 1)); i++)
			g[i] = "0" + g[i];
	}
	int pnt = 0;
	for (int i = 0; i < (1 << df); i++) {
		if (i % 2)
			for (int j = (1 << (sz - df)) - 1; j >= 0; j--)
				ans[pnt++] = bes(f[i], g[j]);
		else
			for (int j = 0; j < (1 << (sz - df)); j++)
				ans[pnt++] = bes(f[i], g[j]);
	}
	cout << "YES" << '\n';
	for (int i = 0; i < n; i++) {
		int tmp = toi(ans[i]) ^ a;
		if (mrk[tmp]) {
			cout << "mrk " << i << endl;
		}
		mrk[tmp] = 1;
		res[i] = toi(ans[i]);
		cout << tmp;
		if (i && dif(res[i], res[i - 1]) > 1) {
			cout << " dif";
		}
		cout << ' ';
	}
	return 0;
}


Measured memory_bytes: 37632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long ;
ll dp[nax][8];
char s[nax];
int n;

int to_int (char x) {
    if (x == 'R') return 0;
    if (x == 'G') return 1;
    if (x == 'B') return 2;

    throw;
}

int main () {
    scanf("%d", &n);
    scanf("%s", s + 1);

    dp[0][0] = 1;

    for (int i = 1 ; i <= n ; ++ i) {
        int x = to_int(s[i]);

        for (int j = 0 ; j < 8 ; ++ j) {
            if (!(j >> x & 1)) {
                dp[i][j | (1 << x)] += dp[i - 1][j];
            }

            dp[i][j] += dp[i - 1][j];
        }
    }

    ll res = dp[n][7];

    for (int len = 1 ; len <= n ; ++ len) {
        for (int i = 1 ; i <= n ; ++ i) {
            if (i + len <= n && i + len + len <= n) {
                if (s[i] != s[i + len] && s[i] != s[i + len + len] && s[i + len] != s[i + len + len])
                    -- res;
            } else break;
        }
    }

    printf("%lld\n", res);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3972
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

#define MAX_N (100005)
int n, m;
vector<int> G[MAX_N];
int Group[MAX_N];

int main()
{
    int id = 0;

    scanf("%d %d", &n, &m);
    
    for ( int i = 0; i < m; i++ ) {
	int s, t;
	scanf("%d %d", &s, &t);
	G[s].push_back(t);
	G[t].push_back(s);
    }

    for ( int i = 0; i < n; i++ ) {
	if ( Group[i] == 0 ) {
	    id++;
	    queue<int> q;
	    q.push(i);
	    Group[i] = id;
	    while ( !q.empty() ) {
		int cur = q.front(); q.pop();
		for ( int j = 0; j < G[cur].size(); j++ ) {
		    int fri = G[cur][j];
		    if ( Group[fri] == 0 ) {
			Group[fri] = id;
			q.push(fri);
		    }
		}
	    }
	}
    }

    int q;
    scanf("%d", &q);

    for ( int i = 0; i < q; i++ ) {
	int s, t;
	scanf("%d %d", &s, &t);
	if ( Group[s] == Group[t] ) {
	    printf("yes\n");
	}
	else {
	    printf("no\n");
	}
    }

    return 0;
}

Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

const ll INF = 1LL << 60;

vector<int> dp(100010, 0);

int main() {
    int N, Q; string S; cin >> N >> Q >> S;
    S = " " + S;
    for (int i = 2; i <= N; i++) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            chmax(dp[i], dp[i - 1] + 1);
        }
        chmax(dp[i], dp[i - 1]);
    }

    for (int t = 0; t < Q; t++) {
        int l, r; cin >> l >> r;
        cout << dp[r] - dp[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll a[n];
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	ll s[n+1];s[0]=0;
	int ans=1;
	rep(i,n){
		s[i+1]=s[i]+a[i];
	}
	for(int i=n-1;i>0;i--){
		if(s[i]*2<a[i]) break;
		else ans++;
	}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
int x[maxn], y[maxn], t[maxn];
 
int dist(int a, int b){
	return abs(x[a] - x[b]) + abs(y[a] - y[b]);
}
 
int main(){
	int n;
	bool ok = 1;
	scanf("%d", &n);
 
	x[0] = 0; y[0] = 0; t[0] = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d%d%d", t + i, x + i, y + i);
	}
 
	for(int i = 0; i < n; i++){
		int d = dist(i, i + 1);
		int cas = t[i + 1] - t[i];
		if(d > cas || ((d & 1) != (cas & 1)))
			ok = 0;
	}
 
	if(ok)
		printf("Yes\n");
	else
		printf("No\n");
 
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e4 + 5 ;
int n ;
char s[maxn] ;
int main()
{
	scanf("%d%s" , &n , s) ;
	int len = strlen(s) ;
	for(int i = 0 ; i < len ; i ++)
	   s[i] = 'A' + (s[i] - 'A' + n) % 26 ;
	printf("%s\n" , s) ;
}

Measured memory_bytes: 256
order = []

for _ in range(5):
  order.append(int(input()))

import numpy as np

order = np.array(order)

order_first = np.sort(((order-1) % 10))+1
order = ((order-1) // 10 + 1) * 10
print(order.sum() + order_first[0] - 10)

Measured memory_bytes: 14208
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] n = new int[4];
		String ans = "NO";
		for(int i = 0; i < 4; i++) {
			n[i] = sc.nextInt();
		}
		Arrays.sort(n);
		if(n[0] == 1 && n[1]== 4) {
			if(n[2] == 7 && n[3] == 9) {
				ans = "YES";
			}
		}
		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <sstream>

std::string func(std::string str){
	std::string res;
	int cnt = 0;
	char c = str[0];
	for (int i = 0; i<str.size(); ++i){
		if (c == str[i])cnt++;
		else{
			if (cnt<10)res.push_back((char)cnt + '0');
			else res+=(std::to_string(cnt));
			res.push_back(c);
			c = str[i];
			cnt = 1;
		}
	}
	if (cnt != 0){
		if (cnt<10)res.push_back((char)cnt + '0');
		else res+=(std::to_string(cnt));
		res.push_back(c);
	}
	return res;
}

int main(){
	int n;
	while (std::cin >> n, n){
		std::string s;
		std::cin >> s;
		for (int i = 0; i < n; ++i){
			//std::cout<<func(s)<<std::endl;
			s = func(s);
		}
		std::cout << s << std::endl;
	}
}

Measured memory_bytes: 1368
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(lint i = s; i < (lint)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  lint X,A = 0,B = 0;
  cin >> X;
  bool sw = false;
  while(sw == false){
    A++;
    rep(i,-A,A+1){
      if((A*A*A*A*A) - (i*i*i*i*i) == X){
        sw = true;
        B = i;
        break;
      }
    }
  }
  cout << A << " " << B;
}

Measured memory_bytes: 3624
def main():
    nm = map(int, raw_input().split())
    A = []
    B = []
    flag = False
    for i in range(nm[0]):
        A.append(raw_input())
    for i in range(nm[1]):
        B.append(raw_input())

    for i in range(nm[0]):
      if i + nm[1] <= nm[0]:
        for j in range(nm[0]):
            if j + nm[1] <= nm[0]:
                for k in range(nm[1]):
                    for l in range(nm[1]):
                        if(A[i+k][j+l] == B[k][l]):
                            flag = True
                        else:
                            flag = False
                            break 
                    if flag == False:
                        break
            else:
                break
            if flag:
                 break
        if flag:
            break
      else:
          break
       
    if flag:
        return "Yes"
    else:
        return "No"    
print main()

Measured memory_bytes: 2696
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = getInt(sc);
		int[] t = getIntArray(sc);

		int m = getInt(sc);
		for (int i = 0; i < m; i++) {
			int p = getInt(sc);
			int x = getInt(sc);
			int sum = 0;
			for (int j = 0; j < n; j++) {
				if (j == p - 1) {
					sum += x;
				} else {
					sum += t[j];
				}
			}
			System.out.println(sum);
		}
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;

const int MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    rep(i, n) {
        ans *= 10;
        ans %= MOD;
    }
    ll tmp = 1;
    rep(i, n) {
        tmp *= 9;
        tmp %= MOD;
    }
    tmp *= 2;
    ll tmp2 = 1;
    rep(i, n) {
        tmp2 *= 8;
        tmp2 %= MOD;
    }
    cout << (ans-tmp+tmp2+MOD+MOD)%MOD << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
struct sushi{
	long long t, d;
}ss[100005];

long long n,k,sum,vis[100005],kinds,ans;
stack<long long> st;
bool cmp(const sushi &x, const sushi &y)
{
	return x.d > y.d;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> ss[i].t >> ss[i].d;
	sort(ss,ss+n,cmp);
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(cnt < k){
			if(vis[ss[i].t]==0){
				vis[ss[i].t] = 1;
				kinds++;	
			}else{
				st.push(ss[i].d);
			}
			sum += ss[i].d;
			cnt++;
			ans = max(ans,sum+kinds*kinds);
		}else{
			if(st.empty()) break;
			if(vis[ss[i].t]) continue;
			vis[ss[i].t] = 1;
			kinds++;
			sum -= st.top();
			sum += ss[i].d;
			st.pop();
			ans = max(ans,sum+kinds*kinds);
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

int main() {
  string s; cin >> s;
  int sn = s.size();
  set<int> S;
  rep(i,sn) S.insert(s[i]);
  int ans = sn;
  for (auto Si : S) {
    int i = 0, mcnt = 0;
    while (i < sn) {
      int cnt = 0;
      if (s[i] != Si) {
        while (s[i] != Si && i < sn) {
          cnt++;
          i++;
        }
      } else {
        i++;
      }
      mcnt = max(mcnt, cnt);
    }
    ans = min(ans, mcnt);
  }
  cout << ans << endl;
  return 0;
}

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

x, y, z, k = map(int, input().split())
a = sorted(int(i) for i in input().split())
b = sorted(int(i) for i in input().split())
c = sorted(int(i) for i in input().split())

#a.sort(reverse=True)
#b.sort(reverse=True)
#c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

print(*abc[:k], sep="\n")

Measured memory_bytes: 162892
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int N;
	cin >> N;
	vector<vector<int>>v(N, vector <int>(3));
	rep(i, N)rep(j, 3)cin >> v[i][j];
	vector<vector<int>>dp(N + 1, vector<int>(3));
	rep(j, 3)dp[0][j] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + v [i][j];
		}
	}
	int ans = max({ dp[N][0],dp[N][1],dp[N][2] });
	cout << ans;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  vector<string> s(3); for(int i = 0; i < 3; ++i) cin >> s[i];
  cout << s[0][0] << s[1][0] << s[2][0] << endl;

  return 0;
}




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

int H, W;
char s[52][52];

int main(){
    cin >> H >> W;

    for(int i=0; i<=H; i++)
        for(int j=0; j<=W; j++)
            s[i][j] = '#';

    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            cin >> s[i][j];

    int cnt = 0;
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            if(s[i][j] == '.') cnt++;

    int d[52][52];
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            d[i][j] = 1<<30;
    d[1][1] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(1, 1));
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    while(!que.empty()){
        auto fr = que.front();
        que.pop();
        int x = fr.first;
        int y = fr.second;
        for(int i=0; i<4; i++){
            int x2 = x + dx[i];
            int y2 = y + dy[i];
            if(d[y2][x2] != 1<<30) continue;
            if(s[y2][x2] == '#') continue;
            d[y2][x2] = d[y][x] + 1;
            que.push(make_pair(x2, y2));
        }
    }
    if(d[H][W] == 1<<30) cout << -1 << endl;
    else cout << cnt - d[H][W] - 1 << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	
	for(int i=1;i<=s.size();i++){
		if(i%2==0 && s[i-1] == 'R'){
			cout << "No" <<endl;
			return 0;
			}
		else if(i%2==1 && s[i-1] == 'L'){
	cout << "No" <<endl;
			return 0;
			}
			}
			cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  int a; cin >> a;
  int b; cin >> b;
  int k; cin >> k;
  vector<int> v;
  forn(i , 1 , 101){
    if(a % i == 0 && b % i == 0) v.push_back(i); 
  }   
  reverse(all(v));
  cout << v[k - 1] << endl;

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

long long modinv(long long a, long long mod) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

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

const vector<long long> MOD = {1000000009, 1000000007};
const vector<long long> BASE = {17, 1009};

long long solve(int N, const string &S) {
    vector<vector<long long>> hash(2, vector<long long>(N+1, 0));
    vector<vector<long long>> pval(2, vector<long long>(N+1, 0));
    map<pair<long long, long long>, vector<int>> pos;

    for (int i = 0; i < N; ++i) {
        for (int it = 0; it < 2; ++it) {
            if (S[i] == '>') {
                hash[it][i+1] = hash[it][i];
                pval[it][i+1] = pval[it][i] + 1;
            }
            else if (S[i] == '<') {
                hash[it][i+1] = hash[it][i];
                pval[it][i+1] = pval[it][i] - 1;
            }
            else if (S[i] == '+') {
                pval[it][i+1] = pval[it][i];
                long long add = modpow(BASE[it], pval[it][i], MOD[it]);
                hash[it][i+1] = (hash[it][i] + add) % MOD[it];
            }
            else if (S[i] == '-') {
                pval[it][i+1] = pval[it][i];
                long long add = modpow(BASE[it], pval[it][i], MOD[it]);
                hash[it][i+1] = (hash[it][i] - add + MOD[it]) % MOD[it];
            }
        }
        pos[{hash[0][i+1], hash[1][i+1]}].push_back(i+1);
    }

    long long res = 0;
    for (int i = 0; i <= N; ++i) {
        vector<long long> risou_add(2), risou(2);
        for (int it = 0; it < 2; ++it) {
            risou_add[it] = hash[it][N] * modpow(BASE[it], pval[it][i], MOD[it]) % MOD[it];
            risou[it] = (hash[it][i] + risou_add[it]) % MOD[it];
        }
        auto &v = pos[{risou[0], risou[1]}];
        int it = upper_bound(v.begin(), v.end(), i) - v.begin();
        res += (int)v.size() - it;  
    }
    return res;
}

int main() {
    int N; string S;
    while (cin >> N >> S) cout << solve(N, S) << endl;
}


Measured memory_bytes: 55136
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

bool used[20][20];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end(),greater<int>());
	ll ans = a[0];
	int d = a[0]; if (d >= 4)d = 4;
	int m = d;
	rep(i, m) {
		rep(j, m) {
			used[i][j] = true;
		}
	}
	rep1(i, n - 1) {
		int ma = 0; int chk = 0;
		rep(j, (1 << m)) {
			vector<int> v;
			rep(k, m) {
				if (j&(1 << k)) {
					v.push_back(k);
				}
			}
			bool f = true;
			rep(k, v.size()) {
				Rep(l, k + 1, v.size()) {
					if (used[v[k]][v[l]])f = false;
				}
			}
			if (f) {
				if (ma < v.size()) {
					ma = v.size();
					chk = j;
				}
			}
		}
		vector<int> v;
		rep(j, m) {
			if (chk&(1 << j))v.push_back(j);
		}
		if (a[i] - ma < 0) {
			rep(j, ma - a[i]) {
				v.pop_back();
			}
			ma = v.size();
		}
		ll dif = a[i] - ma;
		ans += dif;
		if (dif >= 4)dif = 4;
		
		Rep(i, m, m + dif) {
			v.push_back(i);
		}
		m += dif;
		rep(j, v.size()) {
			rep(k, v.size()) {
				used[v[j]][v[k]] = true;
			}
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
#define ld long double
#define rep(i,a,n) for (ll i= (a) ; i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
#define M_PI 3.14159265358979323846
const ll MOD = 1e9 + 7;

void solve() {
	ll n, k; cin >> n >> k;
	vi h(n + 1);
	rep(i, 1, n + 1) cin >> h[i];
	vi dp(n + 1, MOD);
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for ( int i = 3; i <= n; i++) {

		for ( int j = 1; j <= k && i - j >= 1 ; j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}

	}
//    for(auto c:dp) cout<<c<<" ";
//    cout<<endl;
	cout << dp[n] << endl;
}


int main() {

	int t = 1;

	//cin >> t;
	ll k = 1;
	while (t--) {
		//cout << "Case #" << k++ << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 4804
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: i64 = read();
    let y: i64 = read();
    let mut a = 1;
    let mut cnt = 0;

    while a <= y / x {
        cnt += 1;
        a *= 2
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<string> v(n);
  rep(i,n) cin >> v[i];
  int cntAB=0;
  int cntA=0;
  int cntB=0;
  int ans=0;
  rep(i,n){
    string s=v[i];
    rep(j,s.size()-1){
      if(s[j]=='A'&&s[j+1]=='B') ans++;
    }
    if(s[0]=='B'&&s[s.size()-1]=='A') cntAB++;
    else if(s[0]=='B'&&s[s.size()-1]!='A') cntB++;
    else if(s[0]!='B'&&s[s.size()-1]=='A') cntA++;
  }
  if(cntAB==0) ans+=min(cntA,cntB);
  else if(cntA==0&&cntB==0) ans+=cntAB-1;
  else ans+=cntAB-1+min(cntA,cntB)+1;
  cout << ans << endl;
  
}

Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int a_,b_,h_,m_;
  double a,b,h,m;
  cin >> a_ >> b_ >> h_ >> m_;
  a = a_;
  b = b_;
  h = h_;
  m = m_;

  double s,t;
  double d;
  s = 2. * M_PI * (h / 12. + m / (12. * 60.));
  t = 2. * M_PI * m / 60.;
  // cout << s << endl << t << endl;
  double th = s - t;
  // cout << th << endl;
  // cout << cos(th) << endl;

  d = sqrt(
      a * a + b * b - 2. * a * b * cos(th)
      );
  cout << setprecision(20) << d << endl;
}


Measured memory_bytes: 4148
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main(){
    let (n,k) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let an:Vec<i64> = read_vec::<i64>();
    let ans = if (n-k) % (k-1) == 0{
        1 + (n-k) / (k-1)
    } else {
        2 + (n-k) / (k-1)  
    };
    println!("{}",ans );
}

Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int n,k;
        cin>>n>>k;
        int H[50];
        for(int i=0;i<n;i++){
                cin>>H[i];
        }
        sort(H,H+n,greater<int>());
        int ans=0;
        for(int i=0;i<k;i++){
                ans=ans+H[i];
        }
        cout<<ans;
}

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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = 4 * a * b;
  ll e = (c - a - b) * (c - a - b);
  if (c - a - b < 0) {
    cout << "No" << endl;
    return 0;
  }
  if (d < e)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> order(N, 0);
    vector<vector<int>> edge(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        order[a-1]++;
        order[b-1]++;
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }
    for (int i = 0; i < N; i++) {
        if (order[i] % 2 == 1) {
            cout << "No\n";
            return 0;
        }
    }
    vector<int> st;
    for (int i = 0; i < N; i++) {
        if (order[i] >= 6) {
            cout << "Yes\n";
            return 0;
        }
        if (order[i] == 4) {
            st.push_back(i);
        }
    }
    if ((int)st.size() >= 3) {
        cout << "Yes\n";
        return 0;
    }
    if ((int)st.size() <= 1) {
        cout << "No\n";
        return 0;
    }
    
    int start = st[0];
    int goal = st[1];
    queue<pair<int, int>> q;
    q.push({start, -1});
    int path = 0;
    while (!q.empty()) {
        int now = q.front().first;
        int par = q.front().second;
        q.pop();
        for (int nxt : edge[now]) {
            if (nxt == par) continue;
            if (nxt == start) continue;
            if (nxt == goal) {
                path++;
                continue;
            }
            q.push({nxt, now});
        }
    }
    if (path <= 2) {
        cout << "Yes\n";
    }else {
        cout << "No\n";
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)
#define INF 1e9

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1000000000+7;
const int MAX_N=1000;

int main(){
	int n;
	cin>>n;
	int a[n];
	REP(i,n)cin>>a[i];
	sort(a,a+n);
	int small=0;
	int large=0;
	REP(i,n){
		if(a[i]==a[0])small++;
		else if(a[i]==a[0]+1)large++;
	}
	string ans;
	if(small+large!=n)ans="No";
	else if(small==n){
		if(n%2==0 && a[0]<=n/2){
			ans="Yes";
		}else if(n%2!=0 && a[0]<n/2+1){
			ans="Yes";
		}else if(a[0]==n-1){
			ans="Yes";
		}else{
			ans="No";
		}
	}else{
		if(small<a[n-1] && large>=2*(a[n-1]-small)){
			ans="Yes";
		}else{
			ans="No";
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void Zalgorithm(string S, vector<int>& res) {
  res[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    res[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+res[k] < j) res[i+k] = res[k], ++k;
    i += k; j -= k;
  }
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  string Stmp = S;
  vector<int> A(N);
  int ans = 0;
  rep(i, N) {
    Zalgorithm(Stmp, A);
    rep(j, Stmp.size()) {
      ans = max(ans, min(A[j], j));
    }
    Stmp = Stmp.substr(1);
  }
  cout << ans << 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;
using ll = long long;
using P = pair<int, int>;

int main() {
    vector<int> p(5);
    rep(i, 5) cin >> p[i];
    int k;
    cin >> k;
    for (int i = 0; i < 4; ++i) {
    	for (int j = i+1; j < 5; ++j) {
    		if (p[j]-p[i] > k) {
    			cout << ":(" << endl;
    			return 0;
    		}
    	}
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll a,b;
    cin >> a >> b;
    cout << a*b/gcd(a,b) << endl;
}





Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
  int N,M;
  cin>>N>>M;

  vector<int>oks(N+1,true);
  for(int i=0;i<M;++i){
    int a;cin>>a;
    oks[a]=false;
  }

  vector<long long int>dp(N+1);
  dp[0]=1;
  for(int now=0;now<N;++now){
    for(int next=now+1;next<=min(N,now+2);++next){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }

  cout<<dp[N]<<endl;
  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0;i<n;i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    char b;cin>>b;
    if(b=='A')cout<<"T"<<endl;
    else if(b=='G')cout<<"C"<<endl;
    else if(b=='C')cout<<"G"<<endl;
    else cout<<"A"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;


int main() {
  ll N, M, K;
  cin >> N >> M >> K;

  vector<ll> A(N+1,0);
  vector<ll> B(M+1,0);

  for (ll n = 1; n < N+1; n++){
    ll a;
    cin >> a;
    A[n] = a + A[n-1];
  }

  for (ll m = 1; m < M+1; m++){
    ll b;
    cin >> b;
    B[m] = b + B[m-1];
  }

  ll ans = 0;
  ll m = M;

  for (ll n; n <= N; n++ ){
    if (A[n] > K){
      break;
    }

    while (B[m] > K - A[n]){
      m -= 1;
    }

    ans = max({ans,n+m});
  }

  cout << ans << endl;

}


Measured memory_bytes: 6416