akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

void solve() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > field(H);
    vector<vector<int> > used(H);
    for(int y = 0; y < H; ++y){
        field[y].resize(W);
        used[y].resize(W);
        for(int x = 0; x < W; ++x){
            cin >> field[y][x];
        }
    }


    vector< pair<P, P> > ans;
    for(int y = 0; y < H; ++y){
        for(int x = 0; x < W-1; ++x){
            if(field[y][x] % 2 != 0){
                ans.push_back({ {y + 1, x + 1}, {y + 1,x + 2}});
                used[y][x] = 1;
                --field[y][x];
                ++field[y][x+1];
            }
        }
    }

    for(int y = 0; y < H-1; ++y){
        for(int x = 0; x < W; ++x){
            if( field[y][x] % 2 != 0){
                ans.push_back({ {y + 1, x + 1}, {y + 2,x + 1}});
                --field[y][x];
                ++field[y+1][x];
            }
        }
    }

    cout << ans.size() << endl;
    for(auto itr : ans){
        cout << itr.first.first << " " << itr.first.second << " " << itr.second.first << " " << itr.second.second << endl;
    }

    return ;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 8308
n, m = map(int, input().split(" "))

x = list(map(int, input().split(" ")))
y = list(map(int, input().split(" ")))

MOD = 1000000007;

xsum = 0;
ysum=0;
for i in range(n-1) :
	diff = x[i+1] - x[i]
	xsum += diff * (i+1) % MOD * (n-1-i) % MOD
for i in range(m-1) :
	diff = y[i+1] - y[i]
	ysum += diff * (i+1) % MOD * (m-1-i) % MOD
print(xsum * ysum % MOD);

Measured memory_bytes: 18556
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define ll long long int
#define INF 1LL << 62
#define MOD 1000000007
#define fir first
#define sec second
#define all(x) x.begin(), x.end()
using namespace std;

void Main() {
    int n, m;
    cin >> n >> m;
    vector<int> vec(n);
    int l_max, r_min;
    rep(i, 0, m) {
        int l, r;
        cin >> l >> r;
        if (i == 0) {
            l_max = l;
            r_min = r;
        }
        l_max = max({l, l_max});
        r_min = min({r, r_min});
    }
    if (l_max <= r_min) {
        cout << r_min - l_max + 1;
    } else {
        cout << 0 << endl;
    }
    return;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << endl;
    Main();
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	if (a>9||b>9||a<1||b<1) puts("-1");
	else printf("%d\n",a*b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int>p(n);
int cnt =0;
int maxx=999999;
int i;
for(i=0;i<n;i++){
cin>>p[i];
if(maxx>p[i]){
maxx=p[i];
cnt++;
}
}


cout<<cnt;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int dp[500005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string s; cin >> s;
  int n = s.length();
  FOR(i,0,n) {
    if(i>0) dp[i] = max(dp[i], dp[i-1]);
    if(s[i] == '0') {
      int l = 1, r = 1;
      while(i-l>=0&&s[i-l]=='1') l++;
      while(i+r<n&&s[i+r]=='1') r++;
      // 両サイドが1
      if(l > 1 && r > 1) {
        l--;
        r--;
        // 右に行く(あげるdp)
        for(int j = i + 1; j <= i + r; j++) {
          dp[j] = max(dp[j], (i>1?dp[i-2]:0) + j - i);
        }
        // 左に行く(もらうdp)
        for(int j = i - l; j < i; j++) {
          dp[i+1] = max(dp[i+1], (j>0?dp[j-1]:0) + i - j);
        }
      }
    }
  }
  //FOR(i,0,n) cout << dp[i] << endl;
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 2844
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Stars{
public:
	double x;
	double y;
	double z;
	Stars(double _x,double _y,double _z) : x(_x),y(_y),z(_z) {}
};

class Teles : public Stars{
public:
	double phi;
	Teles(double _x,double _y,double _z,double _phi) : Stars(_x,_y,_z),phi(_phi) {}
};

int main(){
	int n,m;
	while(~scanf("%d",&n)){
		if(n==0) break;
		vector<Stars> stars;
		vector<Teles> teles;
		for(int i=0;i<n;i++){
			//stars
			double sx,sy,sz;
			scanf("%lf %lf %lf",&sx,&sy,&sz);
			stars.push_back(Stars(sx,sy,sz));

		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			//telescopes
			double tx,ty,tz,phi;
			scanf("%lf %lf %lf %lf",&tx,&ty,&tz,&phi);
			teles.push_back(Teles(tx,ty,tz,phi));
		}

		int res=0;
		for(int i=0;i<stars.size();i++){

			bool isok = false;			
			for(int j=0;j<teles.size();j++){
				double inner = 
					stars[i].x * teles[j].x
					+ stars[i].y * teles[j].y
					+ stars[i].z * teles[j].z;

				double scaleS = 
					sqrt(stars[i].x * stars[i].x
					+ stars[i].y * stars[i].y
					+ stars[i].z * stars[i].z);

				double scaleT = 
					sqrt(teles[j].x * teles[j].x
					+ teles[j].y * teles[j].y
					+ teles[j].z * teles[j].z);

				double theta = acos(inner/(scaleS*scaleT));

				if(theta < teles[j].phi){
					isok = true;
					break;
				}
			}

			if(isok) res++;
		}

		printf("%d\n",res);
	}
}

Measured memory_bytes: 1324
import numpy as np


def calc_mul4_dp(n, aaa):
    # dp[i] = aaa[i] 以右をascendingにするために4をかける必要のある回数

    # 「支配的」である数と位置を記録するstack
    # 支配的: それを4倍すると、それより右で次に支配的な数までは全て4倍する必要のある数
    # (支配的な数, ←をいじらなかった場合の支配区間の最後の数, 最初の数の位置)
    stack = [(10 ** 20, 10 ** 20, n), (aaa[-1], aaa[-1], n - 1)]
    INF = 10 ** 19
    result = [0, 0]

    for i in range(n - 2, -1, -1):
        a = aaa[i]
        c = a
        inc = 0
        while (c << 2) > stack[-1][0]:
            b, e, j = stack.pop()
            mul = 0
            while c > b:
                b <<= 2
                mul += 1
            inc += mul * (stack[-1][2] - j)
            c = min(e << (2 * mul), INF)
        stack.append((a, c, i))
        result.append(inc)
        # print(a, stack, result)
    result = np.add.accumulate(result, dtype=np.int64)[::-1]
    return result


def solve(n, aaa):
    fdp = calc_mul4_dp(n, aaa)
    bdp = calc_mul4_dp(n, aaa[::-1])[::-1]
    # print(fdp)
    # print(bdp)
    return ((fdp + bdp) * 2 + np.arange(n + 1, dtype=np.int64)).min()


def test():
    import random
    n = 200000
    # aaa = random.choices(range(1, 10 ** 9), k=n)
    # aaa = [1, 10 ** 9] * (n // 2)
    aaa = list(range(10 ** 9, 10 ** 9 - n, -1))
    print(n)
    # print(aaa)
    print(solve(n, aaa))


# test()

n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))


Measured memory_bytes: 34204
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k < n:
            if s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
                ans -= 1
        else:
            break
print(ans)

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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int n;
    cin >> n;
    vector<int> w(n);
    for(int i=0; i<n; i++) {
        cin >> w[i];
    }
    int diff = accumulate(w.begin(), w.end(), 0);
    for(int i=0; i<n; i++) {
        int s1 = accumulate(w.begin(), w.begin() + i, 0);
        int s2 = accumulate(w.begin() + i, w.end(), 0);
        int tmp_diff = abs(s1 - s2);
        if(tmp_diff < diff) {
            swap(diff, tmp_diff); 
        }
    }
    cout << diff << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}


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

int main(){
    
    while(1){
        vector<int> A(10);
    int ans=0;
    for(int i=0;i<10;i++){
        cin>>A[i];
        if(i==0) ans+=A[i];
        else ans-=A[i];
        
        if(i==0&&ans==0) return 0;
    }
    cout<<ans<<endl;
    }
    
}



Measured memory_bytes: 3100
#include <stdio.h>
int main(){
int a,b,temp;
scanf("%d",&a);
scanf("%d",&temp);
if(temp<a)a=temp;
scanf("%d",&temp);
if(temp<a)a=temp;
b=a;
scanf("%d",&a);
scanf("%d",&temp);
if(temp<a)a=temp;
printf("%d\n",a+b-50);
}

Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<int> vs;
    for(int i=0; i<n; i++){
        int tmp;
        scanf("%d", &tmp);
        vs.push_back(tmp);
    }
    int q;
    cin >> q;
    std::vector<int> vt;
    for(int i=0; i<q; i++){
        int tmp;
        scanf("%d", &tmp);
        vt.push_back(tmp);
    }
    int sum = 0;
    for(int i=0; i<vt.size(); i++){
#if 0
        std::vector<int>::iterator itr;
        itr = std::find(vs.begin(), vs.end(), vt[i]);
        if(itr != vs.end()){
            sum++;
        }
#else
        for(int j=0; j<vs.size(); j++){
            if(vt[i] == vs[j]){
                sum++;
                break;
            }
        }
#endif
    }
    cout << sum << endl;
}


Measured memory_bytes: 3336
S = input()[::-1]
N = len(S)

"""
    例： S = '31415926535'
        S[3:8] = '15926535' が 2019 で割り切れるかどうか？
     <=> S[3:-1] - S[8:-1] が 2019 で割り切れるかどうか
     <=> S[3:-1] % 2019 == S[8:-1] % 2019 か
    よって、2019で割ったときの異なるあまりをそれぞれカウントすればよい
"""

mod_cnts = [0] * 2019
mod_cnts[0] = 1 # 累積和のはじめ
current_cusum, ans = 0, 0
# O(N)
d = 1
# for i in range(N):
for s in S:
    current_cusum += int(s) * d
    current_cusum %= 2019
    d = d * 10 % 2019
    mod_cnts[current_cusum] += 1

    # d *= 10 % 2019

# O(2019)
for cnt in mod_cnts:
    ans += cnt * (cnt - 1) // 2 # n_C_2 2つ選ぶ組み合わせ
 
print(ans)


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

int main() {
	int A,B;
	cin>>A>>B;
	int sum=A+B;
	int hik=A-B;
	int kakeru=A*B;
	int maz=sum;
	if(sum<hik)sum=hik;
	if(sum<kakeru)sum=kakeru;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	void run() {

		//
		// 画面入力
		//
		Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] x = new int[N];
    	
    	int x_max = 0;
    	for(int i=0; i<N; i++){
			x[i] = sc.nextInt();
			if(x_max == 0) x_max=x[i];
			if(x[i] > x_max) x_max=x[i];
    	}
    	
		//
		// 処理
		//
    	// テスト
    	// ・境界値 x[i]=0のみ
    	// ・性能  x_max<=100, N<=100のため不要
    	//
    	int sum_min = 0;
    	for(int p = 0; p <= x_max; p++){
    		int sum_tmp = 0;
        	for(int j = 0; j < N; j++){
        		sum_tmp += Math.pow(x[j]-p, 2);
        	}
        	// 初期化
        	if(sum_min==0){
        		sum_min=sum_tmp;
        	}
        	if(sum_tmp < sum_min){
        		sum_min=sum_tmp;
        	}
    	}

		//
		// 画面出力
		//
    	System.out.println(sum_min);

		//
		// 後処理
		//
    	sc.close();
	}
	
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main() 
{
	FAST
	ll n;
	ld sum=0;
	cin>>n;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=(1.0/a[i]);
	}
	printf("%Lf",(1.0/sum));
	return 0;
}

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



int main(){
    int n;
    cin >> n;
    vector <float> v(n);
    const float inf = 1e4;
    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> v[tsumugi];
    }

    sort(v.begin(), v.end());
    
    for (int matsuri = 0; matsuri < n - 1; matsuri++){
        float min1 = v[matsuri];
        float min2 = v[matsuri + 1];
        // cout << min1 << endl;
        // cout << min2 << endl;
        v[matsuri] = inf;
        v[matsuri + 1] = (min1 + min2) / 2;
        // cout << v[matsuri] << endl;
        // cout << v[matsuri + 1] << endl;
    }
    cout << v[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#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)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
vector<vector<pair<int, int> > > A;
int N;
int ans;
vector<int> memo;
bool test(int tmp) {
  for(auto a: A[tmp]) {
    if(a.second && (memo[a.first] == -1 || memo[a.first] == 1)) continue;
    if(!a.second && (memo[a.first] == -1 || memo[a.first] == 0)) continue;
    return false;
  }
  return true;
}
void dfs(int tmp, int par, int value) {
  if(tmp == N) {
    ans = max(ans, value);
    return;
  }
  vector<int> backup(N, -1);
  rep(i, N) backup[i] = memo[i];
  bool ret = test(tmp);
  if(!ret && memo[tmp] == 1) return;
  if(memo[tmp] == 1) {
    for(auto a: A[tmp]) memo[a.first] = a.second;
    dfs(tmp+1, tmp, value+1);
    rep(i, N) memo[i] = backup[i];
  } else if(memo[tmp] != 0 && ret) {
    memo[tmp] = 1;
    for(auto a: A[tmp]) memo[a.first] = a.second;
    dfs(tmp+1, tmp, value+1);
    rep(i, N) memo[i] = backup[i];
    memo[tmp] = 0;
    dfs(tmp+1, tmp, value);
    rep(i, N) memo[i] = backup[i];
  } else {
    memo[tmp] = 0;
    dfs(tmp+1, tmp, value);
    rep(i, N) memo[i] = backup[i];
  }
}
int main() {
  cin >> N;
  A = vector<vector<pair<int, int> > >(N);
  memo = vector<int>(N, -1);
  rep(i, N) {
    int a;
    cin >> a;
    rep(j, a) {
      int x, y;
      cin >> x >> y;
      x--;
      A[i].push_back(make_pair(x, y));
    }
  }
  dfs(0, -1, 0);
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1)
    {
        C = C - B;
        if ( C <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
import sys,math,copy,queue,itertools,bisect
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
x,y,z = LI()
x,y = y,x
x,z = z,x
print (x,y,z)

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

#define pb push_back
#define f first 
#define s second
#define ll long long

ll n, m, q;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> m >> q;
    cout << (n+m+q >= 22?"bust\n":"win\n");
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int n;
    string s;
    char now = 'A';
    cin >> n;
    cin >> s;
    REP(i, n){
        if(now != s[i]){
            now = s[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

struct Event {
    int time, event, place;
    bool operator<(const Event &r) const {
        return time != r.time ? time < r.time : event < r.event;
    }
};

int n, q;
vector<Event> vec;
set<int> st;

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

    cin >> n >> q;
    rep(i, n) {
        int s, t, x;
        cin >> s >> t >> x;
        vec.push_back({s - x, 1, x});
        vec.push_back({t - x, 0, x});
    }
    rep(i, q) {
        int d;
        cin >> d;
        vec.push_back({d, 2, 0});
    }

    sort(ALL(vec));

    rep(i, vec.size()) {
        switch(vec[i].event) {
        case 0:
            st.erase(vec[i].place);
            break;
        case 1:
            st.insert(vec[i].place);
            break;
        case 2:
            cout << (st.size() ? *st.begin() : -1) << endl;
        }
    }
}

Measured memory_bytes: 19176
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <cassert>
#include <tuple>
#include <list>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef long double ld;

template<class htpe, class cmp>
using heap = priority_queue<htpe, vector<htpe>, cmp>;

template<class htpe>
using min_heap = heap<htpe, greater<htpe> >;

template<class htpe>
using max_heap = heap<htpe, less<htpe> >;

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define ff first
#define ss second

#define forn(i, n) for (int i = 0; i < ((int)(n)); ++i)
#define forrn(i, s, n) for (int i = (int)(s); i < ((int)(n)); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))

const int INF = 1791791791;
const ll INFLL = 1791791791791791791ll;


int main() {
    // Code here:

    int n;
    cin >> n;

    int x = 0, y = 0, t = 0;

    forn(i, n) {
        int nx, ny, nt;
        cin >> nt >>  nx >> ny;
        if (abs(nx - x) + abs(ny - y) > nt - t) {
            cout << "No" << endl;
            return 0;
        }
        if ((abs(nx - x) + abs(ny - y)) % 2 != (nt - t) % 2) {
            cout << "No" << endl;
            return 0;
        }
        x = nx, y = ny, t = nt;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,z,i,max;

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

  if(x==y) max=x;
  
 else if(x>=y){
    z=x%y;
    for(i=z;i>0;i--){
    if(z%i==0){
      if(y%i==0){
	max=i;
	break;
      }
    }
  }
  }
  else{
    z=y%x;
    for(i=z;i>0;i--){
    if(z%i==0){
      if(y%i==0){
	max=i;
	break;
      }
    }
    }
  }
  printf("%d\n",max);
  
  
  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,k; cin>>n>>k;
	int ans=1;
	rep(i,0,n){
		ans=min(ans*2,ans+k);
	}
	cout<<ans<<endl;
	
	return 0;
}

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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int N,K;
    cin >> N >> K;
    if(N==0) cout << 1 << endl;
    int i=0,count=0;
    while(N!=0){
        N = N/K;
        count++;
    }
    cout << count << endl;
    return  0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
ll N, A, B;
bool check(ll num, vector<ll> h)
{
    ll cnt = 0;
    for(int i = 0; i < h.size(); i++) h[i] -= num * B;
    ll d = A - B;
    for(int i = 0; i < h.size(); i++)
    {
        if(h[i] <= 0) continue;
        cnt += (h[i] + d - 1) / d;
    }
    return (cnt <= num);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> A >> B;
    vector<ll> h(N);
    for(int i = 0; i < N; i++) cin >> h[i];
    ll ng = 0, ok = INF;
    while(abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        if(check(mid, h)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}



Measured memory_bytes: 1792
n,k=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)

INF=100000000
dp=Array.new(n,INF)

dp[0]=0
for i in 1..n-1
    if i==1
        dp[i]=(h[i]-h[i-1]).abs
    else
    dp[i]=[]
    for j in 1..k
        if j>i
        break
        end
        dp[i]<<dp[i-j]+(h[i-j]-h[i]).abs
        
    end

    dp[i]=dp[i].min
   
    end
    
end

p dp[-1]

Measured memory_bytes: 91184
#include <stdio.h>

void sort(int a[],int n);

int main()
{
  int n,k,i,ans=0;
  int p[1000];

  scanf("%d %d",&n,&k);

  for(i=0; i<n; i++)
    scanf("%d", &p[i]);

  sort(p,n);
  for(i=0; i<k; i++)
    ans += p[i];
  printf("%d\n",ans);

  return 0;
}

void sort(int a[],int n)
{
  int i,j,idx;
  int min;

  for(i=0; i<n; i++)
  {
      idx = i; min = a[i];
      for(j=i+1; j<n; j++)
      {
        if(a[j] < min) {
          min = a[j];
          idx = j;
        }
      }
      a[idx] = a[i];
      a[i] = min;
  }
}


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

using ll = long long;
const ll M = 1000000007;
ll fac[200001];


ll qpow(ll a,ll p,ll mod)
{
    ll ans = 1;
    while (p) {
        if (p&1) ans = (ans*a)%mod;
        a = (a*a)%mod;
        p >>= 1;
    }
    return ans;
}


void exgcd(ll a,ll b,ll& d,ll& x,ll& y)
{
    if (!b) {
        d=a; x=1; y=0;
    } else {
        exgcd(b,a%b,d,y,x); y-=x*(a/b);
    }
}


ll inv(ll a,ll mod)
{
    ll d, x, y;
    exgcd(a, mod, d, x, y);
    return (d == 1) ? (x+mod)%mod : -1;
}


ll C(ll n,ll m,ll mod)
{
    if (n<m) return 0;
    if (n<mod && m<mod)
        return fac[n]*inv(fac[m],mod)%mod*inv(fac[n-m],mod)%mod;
    return C(n/mod,m/mod,mod)*C(n%mod,m%mod,mod)%mod;
}


void init(int n, ll mod)
{
    fac[0] = 1;
    for(int i=1; i<=n; i++)
        fac[i] = (fac[i-1]*i)%mod;
}


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

    init(200000, M);
    ll ans = C(W-1+H-1, W-1, M);
    for (int x = 1; x <= A; x++) {
        ans -= C(H-x+B-1, B-1, M) * C(W-B-1+x-1, x-1, M) % M;
        if (ans < 0) ans += M;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.math.*;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int cnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '2') {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
program ABC047C
    implicit none
    integer(8)::i
    integer(8)::result=0
    character(100000)::S

    read(5,*)S

    do i=1,len_trim(S)-1
        if(S(i:i)/=S(i+1:i+1))then
            result=result+1
        end if
    end do

    print'(i0)',result
    
end program ABC047C

Measured memory_bytes: 1084
from copy import copy
N, M = map(int, input().split())
br = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    br[a-1].append(b-1)
    br[b-1].append(a-1)
ans = 0
stack = []
seen = [False]*N
seen[0] = True
stack.append((0, copy(seen)))
while len(stack):
    n, s = stack.pop()
    f = False
    for m in br[n]:
        if not s[m]:
            s2 = copy(s)
            s2[m] = True
            stack.append((m, s2))
            f = True
    if not f and not False in s:
        ans += 1
print(ans)


Measured memory_bytes: 41692
#include<bits/stdc++.h>
using namespace std;
int main() {
	set<string> s;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		string t;
		cin>>t;
		s.insert(t);
	}
	cout<<s.size();
	return 0;
}


Measured memory_bytes: 19124
import math

def comb(n):
    if n-2<0:
        return 0
    return math.factorial(n)//(math.factorial(2)*math.factorial(n-2))
    
N=int(input())
A=list(map(int,input().split()))

nums=[0 for i in range(N+1)]
for i in range(N):
    nums[A[i]]+=1

num=0
for i in range(len(nums)):
    num+=comb(nums[i])

for i in range(N):
    ans=num-(nums[A[i]]-1)
    print(ans)

Measured memory_bytes: 118712
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, q) = readListOfInt()
    val s = read()
    val lr = mutableListOf<Pair<Int, Int>>()
    for(i in 0 until q) {
        val (l, r) = readListOfInt()
        lr.add(Pair(l, r))
    }
    val cSum = (0..n).map { 0 }.toMutableList()
    cSum[0] = 0
    for(i in 2..n) {
        cSum[i] = cSum[i-1] + if(s[i-2] == 'A' && s[i-1] == 'C') 1 else 0
    }
    for(i in 0 until q) {
        val (l, r) = lr[i]
        println(cSum[r] - cSum[l])
    }
    //println(cSum)
    
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 73308
#include<cstdio>
#define mx 100005
#define For(n) for(int i;i<n;i++)
using namespace std;
int n,m,p[mx],b[mx],c[mx];
long long a[mx];
int f(int s){
  int t=p[s];
  return t<0?s:p[s]=f(t);
}
long long g(int j){
  int x=f(b[j]),y=f(c[j]),s=0,t;
  if(x!=y){
    s=p[x],t=p[y];
    p[x]=y;
    p[y]+=s;
  }
  return 1ll*s*t;
}
int main(){
  scanf("%d%d",&n,&m);
  a[m-1]=1ll*n*(n-1)/2;
  For(n)p[i]=-1;
  For(m)scanf("%d%d",&b[i],&c[i]);
  for(int i=m-2;i>=0;i--)a[i]=a[i+1]-g(i+1);
  For(m)printf("%lld\n",a[i]);
}

Measured memory_bytes: 3200
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psl = pair<string, ll>;

template <ll MOD>
struct ModLL {
  ll val;
  ModLL() : val(0) {}
  ModLL(ll v) : val(v >= 0 ? v % MOD : (MOD - (-v) % MOD) % MOD) {}

  ModLL operator-() const { return ModLL(-val); }

  ModLL& operator+=(const ModLL& r) {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return (*this);
  }
  ModLL operator+(const ModLL& r) const { return ModLL(*this) += r; }

  ModLL& operator-=(const ModLL& r) {
    val += MOD - r.val;
    if (val >= MOD) val -= MOD;
    return (*this);
  }
  ModLL operator-(const ModLL& r) const { return ModLL(*this) -= r; }

  ModLL& operator*=(const ModLL& r) {
    val *= r.val;
    if (val >= MOD) val %= MOD;
    return (*this);
  }
  ModLL operator*(const ModLL& r) const { return ModLL(*this) *= r; }

  ModLL& operator/=(const ModLL& r) {
    (*this) *= r.inv();
    return (*this);
  }
  ModLL operator/(const ModLL& r) const { return ModLL(*this) /= r; }

  bool operator==(const ModLL& r) { return val == r.val; }
  bool operator!=(const ModLL& r) { return val != r.val; }

  ModLL pow(ll n) const {
      ll tmp = val;
      ll ret = 1;
      while (n > 0) {
          if (n & 0x01) {
              ret *= tmp;
              ret %= MOD;
          }
          tmp = tmp * tmp;
          tmp %= MOD;
          n >>= 1LL;
      }
      return ModLL(ret);
  }

  ModLL inv() const {
    ll a = val, b = MOD, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModLL(u);
  }

  friend istream& operator>>(istream& is, ModLL<MOD>& r) {
    ll t;
    is >> t;
    r = ModLL<MOD>(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModLL<MOD>& r) {
    return os << r.val;
  }

  ModLL comb(ll n, ll k) {
    ModLL x = 1, y = 1;
    REP(i, k) {
      x *= n - i;
      y *= i + 1;
    }
    return x / y;
  }
};


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

  const ll MOD = 1e9 + 7;
  ll N, A, B;
  cin >> N >> A >> B;

  if (N == 2) {
    cout << 0 << endl;
    return 0;
  }

  ModLL<MOD> two(2);
  ModLL<MOD> ans = two.pow(N);
  ans -= 1;
  ModLL<MOD> Num(N);

  ans -= Num.comb(N, A);
  ans -= Num.comb(N, B);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, x,y,z, m;

	for(scanf("%d",&i); i>0; i--){
		scanf("%d %d %d",&x, &y, &z);
		m = x>y ? (x>z ? (x*x-y*y-z*z) : (z*z-x*x-y*y)) : ( y>z ? (y*y-x*x-z*z) : (z*z-x*x-y*y)) ;
		if(m)
			printf("NO\n");
		else
			printf("YES\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	// VL p(n),q(n);
	// fr(i,0,n)
	// 	rl(p[i]);
	string p="",q="",r="";
	fr(i,0,n)
		{
			char x;
			cin>>x;
			p+=x;
			char y='1'+i;
			r+=y;
		}	
	fr(i,0,n)
		{
			char x;
			cin>>x;
			q+=x;
		}
	ll x=0,y=0,ct=0;
	do
	{
		if(p==r)
			x=ct;
		if(q==r)
			y=ct;
		ct++;
	}while(next_permutation(ALL(r)));
	//cout<<p<<" "<<q<<" "<<r<<endl;
	ll ans=abs(x-y);
	wl(ans);
	NL;
	return 0;
}

Measured memory_bytes: 256
import sys
import os
import math

def lcm(a, b):
    return a*b//math.gcd(a,b)

def main():
    while True:
        a = input().split(" ")
        a1 = int(a[0])
        m1 = int(a[1])
        a2 = int(a[2])
        m2 = int(a[3])        
        a3 = int(a[4])
        m3 = int(a[5])
        if a1 is 0:
            break        
        i = 1
        xyz = [a1%m1, a2%m2, a3%m3]
        temp = [0, 0, 0]
        if math.gcd(a1, m1) is math.gcd(a2, m2) is math.gcd(a3, m3) is 1:
            while True:
                if xyz[0] is xyz[1] is xyz[2] is 1:
                    break
                i += 1
                xyz = [(xyz[0]*a1)%m1, (xyz[1]*a2)%m2, (xyz[2]*a3)%m3]
                if xyz[0] is 1:
                    temp[0] = i
                    xyz[0] = 0
                if xyz[1] is 1:
                    temp[1] = i
                    xyz[1] = 0
                if xyz[2] is 1:
                    temp[2] = i
                    xyz[2] = 0
                if xyz[0] is xyz[1] is xyz[2] is 0:
                    break
            tmp = lcm(temp[0], temp[1])
            tmp = lcm(tmp, temp[2])
            print(tmp)
        else:
            print("error")

main()

Measured memory_bytes: 5672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

ll dp[110][110000];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ll W; cin >> W;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=100000;j++){
			dp[i][j]=1e10;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		ll w,v; cin >> w >> v;
		for(int j=0;j<=100000;j++){
			if(dp[i][j]==1e10)continue;
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			dp[i+1][j+v]=min(dp[i+1][j+v],dp[i][j]+w);
		}
	}
	for(int i=1e5;i>=0;i--){
		if(dp[n][i]<=W){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 88192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   string s;
   cin >> s;
   if (s[s.size()-1] == '2' || s[s.size()-1] == '4' || s[s.size()-1] == '5' || s[s.size()-1] == '7' || s[s.size()-1] == '9') cout << "hon" << endl;
   else if (s[s.size()-1] == '0' || s[s.size()-1] == '1' || s[s.size()-1] == '6' || s[s.size()-1] == '8') cout << "pon" << endl;
   else if (s[s.size()-1] == '3') cout << "bon" << endl;

   return 0; 

}


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

int main(void) {
    int n;
    cin >> n;
    int maxv;
    vector<int> t;
    int minv[n];
    for (int i = 0 ; i < n; i++) {
        int num;
        cin >> num;
        t.push_back(num);
        if (i == 1) {
            maxv = t.at(i) - t.at(i-1);
            minv[i] = min(t.at(i), t.at(i-1));
        } else if (i > 1) {
            maxv = max(maxv, t.at(i) - minv[i-1]);
            minv[i] = min(t.at(i), minv[i-1]);
        }
    }
    printf("%d\n", maxv);
    return 0;
}


Measured memory_bytes: 4588
ans li | li == "SUN" = 7
       | li == "MON" = 6
       | li == "TUE" = 5
       | li == "WED" = 4
       | li == "THU" = 3
       | li == "FRI" = 2
       | otherwise   = 1


main = do
  li <- getLine
  putStrLn $ show $ ans li


Measured memory_bytes: 3808
#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() {
    ll X, Y;
    cin >> X >> Y;
    int ans = 1;
    while (X * 2 <= Y) {
        X *= 2;
        ++ans;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3592
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    vll l(n);
         
    rep(i, n) {
        cin >> l[i];
    }
    
    // 各 p の値に対して

    
    Sort(l);
    
    rep(i, n-2) {
        for(ll j = i+1; j < n-1; j++) {
            for(ll k = j+1; k < n; k++) {
                if (l[i] == l[j] || l[j] == l[k]) continue;
                if (l[i] + l[j] > l[k]) cnt ++;
            }
            
        }
    }
    
    mes(cnt);
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  double A[N];
  REP(i, N) cin >> A[i];
  double ans = 0;
  REP(i, N) ans += 1/A[i];
  ans = 1/ans;
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int N = 10;

int main() {
  int sum = 0;
  REP(i, N){
    int tmp; cin >>tmp; sum += tmp;
  }
  cout <<sum <<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
string s;
int main() {
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
def partition(a, p, r)
  unused, x = a[r].split(' ')
  i = p - 1
  p.upto(r-1) do |j|
    unused, aj = a[j].split(' ')
    if aj.to_i <= x.to_i
      i = i + 1
      a[i], a[j] = a[j], a[i]
    end
  end
  a[i+1], a[r] = a[r], a[i+1]
  return i + 1
end

def quickSort(a, p, r)
  if p < r
    q = partition(a, p, r)
    quickSort(a, p, q-1)
    quickSort(a, q+1, r)
  end
end

def checkStable(origin, sorted)
  originOrder = {}
  sortedOrder = {}
  (origin.size).times do |i|
    alphabet, num = origin[i].split(' ')
    originOrder[num.to_i] = originOrder[num.to_i] == nil ? alphabet.to_s : originOrder[num.to_i] + alphabet.to_s
    alphabet, num = sorted[i].split(' ')
    sortedOrder[num.to_i] = sortedOrder[num.to_i] == nil ? alphabet.to_s : sortedOrder[num.to_i] + alphabet.to_s
  end
  return originOrder == sortedOrder ? 'Stable' : 'Not stable'
end

a = []
n = gets.to_i
n.times do
  a.push(gets.to_s)
end
origin = Marshal.load(Marshal.dump(a))
quickSort(a, 0, a.size-1)
puts checkStable(origin, a)
puts a

Measured memory_bytes: 36692
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

#include<vector>
#include<algorithm>
#include<map>
namespace ProconLib{
    template<typename T>
    std::map<T,int> Compress(std::vector<T> v){
        sort(v.begin(),v.end());
        v.erase(unique(v.begin(),v.end()),v.end());
        std::map<T,int> res;
        int id=0;
        for(auto &x:v){
            res[x]=id++;
        }
        return res;
    }
}
#include<vector>
namespace ProconLib{

    //Summation only
    template<typename Int>
    struct BIT{     
        private:
        int N;
        std::vector<Int> dat;
        public:
        BIT(int N):N(N),dat(N,0){}
        void add(int pos,Int x);
        Int query(int r);
        Int query(int l,int r);
    };

    template<typename Int>
    void BIT<Int>::add(int pos,Int x){
        pos++;
        while(pos<=N){
            dat[pos-1]+=x;
            pos+=pos&-pos;
        }
    }

    template<typename Int>
    Int BIT<Int>::query(int r){
        Int res=0;
        while(r>0){
            res+=dat[r-1];
            r-=r&-r;
        }
        return res;
    }

    template<typename Int>
    Int BIT<Int>::query(int l,int r){
        return query(r)-query(l);
    }
  
};
using namespace ProconLib;

const ll MOD=998244353;
struct P{
    int id;
    int x,y;
};
int main(){
    int n;
    cin>>n;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    auto mpX=Compress(x);
    auto mpY=Compress(y);
    vector<P> ps(n);
    for(int i=0;i<n;i++){
        ps[i].id=i;
        ps[i].x=mpX[x[i]];
        ps[i].y=mpY[y[i]];
    }

    
    vector<vector<int>> a(n,vector<int>(4));
    {
        BIT<ll> lefb(n),rigb(n);
        sort(ps.begin(),ps.end(),[](P lhs,P rhs){return lhs.x<rhs.x;});
        for(int i=0;i<ps.size();i++) rigb.add(ps[i].y,1);
        for(int i=0;i<ps.size();i++){
            a[ps[i].id][0]=rigb.query(ps[i].y+1,n);
            a[ps[i].id][1]=lefb.query(ps[i].y+1,n);
            a[ps[i].id][2]=lefb.query(0,ps[i].y);
            a[ps[i].id][3]=rigb.query(0,ps[i].y);
            lefb.add(ps[i].y,1);
            rigb.add(ps[i].y,-1);
        }
    }
    vector<ll> pow2(1e6);
    pow2[0]=1;
    for(int i=0;i+1<pow2.size();i++){
        pow2[i+1]=pow2[i]*2%MOD;
    }
    ll res=n*(pow2[n]-1)%MOD;
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            res-=(pow2[a[i][j]+a[i][(j+1)%4]]-pow2[a[i][j]]);
        }
        res%=MOD;
    }
    res=(res+MOD)%MOD;
    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 41656