akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];
    REP(i, n) sort(ALL_OF(s[i]));
    sort(ALL_OF(s));

    ll ans = 0;
    for (ll i = 0; i < n;) {
        ll j;
        for (j = i+1; j < n && s[i] == s[j]; j++);
        ll num = j - i;
        ans += num * (num - 1) / 2;
        i = j;
    }
    cout << ans << endl;
    
}

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

class Team{
  public:
    int id;
    int solvednum;
    int penalty;
    vector<bool> solved;
    vector<int> WA;
    Team(int id, int N){
      this->id = id;
      solvednum = 0;
      penalty = 0;
      solved.resize(N, false);
      WA.resize(N, 0);
    }
    bool operator == (const Team &t)const{
      return id == t.id;
    }
    bool operator < (const Team &t)const{
      if(solvednum == t.solvednum){
        if(penalty == t.penalty){
          return id > t.id;
        }
        return penalty < t.penalty;
      }
      return solvednum > t.solvednum;
    }
    string toString(){
      return to_string(id) + " " + to_string(solvednum) + " " + to_string(penalty);
    }
};

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int M, T, P, R;
  while(cin >> M >> T >> P >> R, M | T | P | R){
    vector<Team> teams;
    for(int i = 0;  i < T; i++){
      teams.push_back(Team(i+1, P+1));
    }
    for(int asd = 0; asd < R; asd++){
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--;
      if(j == 0){
        teams[t].solved[p] = true;
        teams[t].solvednum++;
        teams[t].penalty += m + 20*teams[t].WA[p];
      }else{
        teams[t].WA[p]++;
      }
    }
    sort(teams.begin(), teams.end());

    cout << teams[0].id;
    for(int i = 1; i < T; i++){
      if(teams[i].solvednum == teams[i-1].solvednum && teams[i].penalty == teams[i-1].penalty){
        cout << '=';
      }else{
        cout << ',';
      }
      cout << teams[i].id;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3132
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        self.group_num -= 1



U = UnionFind(10 ** 5 * 2)
n = I()
X = []
Y = []
for _ in range(n):
    x, y = LI()
    U.union(x - 1, y - 1 + 10 ** 5)


XD = defaultdict(int)
YD = defaultdict(int)
for i in range(10 ** 5 * 2):
    if i < 10 ** 5:
        XD[U.root(i)] += 1
    else:
        YD[U.root(i)] += 1


ret = 0
for j in range(10 ** 5 * 2):
    ret += XD[j] * YD[j]


print(ret - n)







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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;

#define solve imAwesome
#define for0(i,n) for(int i=0; i<(int)n; i++)
#define forn(i,n) for(int i=1; i<=(int)n; i++)
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define endl cout << "\n";
#define debug cout << "Aqui\n";
#define deb(i) cout << "Aqui " << (ll) i << "\n";
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286L

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	
	ld a,b,h,m;
	cin >> a >> b >> h >> m;
	ld alfa = PI * 2 * ( (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
	ld ans = (ld)(a*a+b*b)-2.0*(ld)a*(ld)b*cos(alfa);
	cout << std::setprecision(12) << sqrt(ans) << "\n";
	return 0;

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll num[101010];
ll dp[110][101010];
ll tmp[101010];

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

    ll N, K;
    cin >> N >> K;

    REP(i, 101010) num[i] = 0;
    ll ma = 0;
    for(int i=1;i<=N;){
    	int j = N/i;
    	if(i <= j){
    		num[ma] = 1;
    		i++;
    		ma++;
    	}else{
    		num[ma] = N/j - i + 1;
    		i = N/j + 1;
    		ma++;
    	}
    }

    /*
    REP(i, ma) cout << num[i] << " ";
    cout << endl;
    dump(ma)
    */

    REP(i, 110)REP(j, 101010) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(i, K){
    	REP(j, 101010) tmp[j] = 0;
    	REP(j, ma+1){
    		tmp[j+1] = tmp[j] + dp[i][j];
    		tmp[j+1] %= mod;
    	}
    	REP(j, ma){
    		dp[i+1][j] = (tmp[ma-j] * num[j])%mod;
    		dp[i+1][j] %= mod;
    	}
    }

    ll res = 0;
    REP(j, ma){
    	res += dp[K][j];
    	res %= mod;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 88704
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

struct UnionFind
{
    vector<long long> d;
    UnionFind(long long n = 0) : d(n, -1)
    {
    }

    //root : -size, not root: root
    long long root(long long x){
        if(d[x] < 0){
            return x; 
        }
        return d[x] = root(d[x]);
    }

    bool unite(long long x, long long y){
        x = root(x);
        y = root(y);
        if(x == y){
            return false;
        }
        if(d[x] > d[y]){
            swap(x, y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    long long size(long long x){
        return -d[root(x)];
    }

    bool issame(long long a, long long b){
        return root(a) == root(b);
    }
};

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, m; cin >> n >> m;
    vector<ll> p(n);
    rep(i, n){
        ll tmp; cin >> tmp; tmp--;
        p[i] = tmp;
    }

    UnionFind uf(n);

    rep(i, m){
        ll x, y; cin >> x >> y; x--; y--;
        if(!uf.issame(x, y)){
            uf.unite(x, y);
        }
    }

    ll ans = 0;
    rep(i, n){
        if(uf.issame(p[i], i)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#define INFTY 1<<21
#define rep(i,n) for(i=0;i<n;i++)
int mat[20][20];
int dijkstra(int s,int g,int n)
{
  int cost[20],id,i,c;
  char used[20]={0};
  memset(cost,0x5f,sizeof(cost));cost[s]=0;
  for(;id=-1;){
    rep(i,n)if(!used[i]&&(id==-1||cost[i]<cost[id]))id=i;
    if(id<0)break;
    used[id]=1;
    rep(i,n){
      c=cost[id]+mat[id][i];
      if(cost[i]>c)cost[i]=c;
    }
  }
  return cost[g];
}
int main(void)
{
  int n,m,a,b,c,d,i;
  scanf("%d%d",&n,&m);
  memset(mat,0x5f,sizeof(mat));
  rep(i,m){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--;b--;
    mat[a][b]=c;mat[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--;b--;
  printf("%d\n",c-dijkstra(a,b,n)-dijkstra(b,a,n)-d);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int flag = 0;
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int len = sizeof(arr) / sizeof(int);
  sort(arr, arr + len);
  int c;
  for (int j = 0; j < n; j++) {
    if (j == 0) {
      c = arr[j];
      // cout << "j==0_" << arr[j] << endl;
    }
    if (j != 0) {
      if (c == arr[j]) {
        // cout << "c==arr[j]_" << arr[j] << endl;
        flag++;
        break;
      } else {
        c = arr[j];
        // cout << "c==arr[j]に置き換える" << arr[j] << endl;
      }
    }
  }
  if (flag != 0) {
    cout << "NO";
  }
  if (flag == 0) {
    cout << "YES";
  }
  return 0;
}
// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
double a,b,x,h,t;
double pai=acos(-1);
double find(double l,double r) {
	while (r-l>=1e-7) {
		double mid=(l+r)/2;
		if (tan(mid*pai/180)<t) l=mid;
		else r=mid;
	}
	return r;
}
int main() {
	scanf("%lf%lf%lf",&a,&b,&x);
	h=x/(a*a);
	if (h*2>=b) {
		double c=h*2-b;
		double delta=b-c;
		t=delta/a;
	} else {
		double d=2*x/(a*b);
		t=b/d;
	}
	printf("%.7lf\n",find(0.0,90.0));
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int n, a[50];
int solve(int i, int m) {
    // 再帰終了条件 成功条件
    if (m == 0) {
        return true;
    }
    // 再帰終了条件 失敗条件
    if (i >= n) {
        return false;
    }
    // 考えるポイント
    // 左はi番目を使わないで次へ、右はi番目（a[i]）を削って次へ。
    // つまり、i番目を使うかどうかの両方のパターンで再帰をかける。
    // ただそれだけ。
    int res = solve(i + 1, m) || solve(i + 1, m - a[i]);
    // このresを見ることで再帰でどこまで深く潜っているかわかる。
    // cout << res << " ";

    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int q, m, i;
    cin >> n;
    rep(i, n) cin >> a[i];
    cin >> q;
    rep(i, q) {
        cin >> m;
        // この0はiが0から始まっている。
        // mは求める数。
        if (solve(0, m))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}



Measured memory_bytes: 3204
#!/usr/local/bin/ruby
n=gets.to_i
n.times{
x1,y1,x2,y2,x3,y3,x4,y4=gets.split.map(&:to_f)
ab=(y2-y1)/(x2-x1)
cd=(y4-y3)/(x4-x3)
  if ab==cd
    puts"YES"
  else 
    puts"NO"
  end  
}

Measured memory_bytes: 6124
import bisect
n = int(input())
a = list(map(int, input().split()))

cum = [0]
for ai in a:
    cum.append(cum[-1] + ai)

ans = float('inf')

for i in range(2, n-1):
    bc = cum[i]
    de = cum[-1] - cum[i]
    bc_mid = bc / 2
    de_mid = (cum[i] + cum[-1]) / 2

    i_bc = bisect.bisect_left(cum, bc_mid)
    i_de = bisect.bisect_left(cum, de_mid)

    # print(i_bc)
    # print(i_de)

    for cum_b in (cum[i_bc-1], cum[i_bc]):
        for cum_d in (cum[i_de-1], cum[i_de]):
            b = cum_b
            c = bc - b
            d = cum_d - bc
            e = de - d
            bcde = [b, c, d, e]
            bcde.sort()
            ans = min(ans, bcde[-1]-bcde[0])

print(ans)

Measured memory_bytes: 24796
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    for(long long i=1;i<=INF;i++){
        if(abs(A-i) == abs(B-i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split(' ');
  const N = parseInt(args[0]);
  const A = parseInt(args[1]);
  const B = parseInt(args[2]);
  
  const nums = Array.from(new Array(N), (v, i) => ++i).filter((i) => {
  	var n = i.toString().split('').reduce((p, c) => p + parseInt(c), 0);
    return (A <= n && n <= B);
  });
  
  console.log(nums.reduce((p, c) => p + c, 0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9968
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define Rep(i,a,b) for(ll i=a;i<b;i++)
#define pb emplace_back
#define allv v.begin(),v.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define FASTio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<(#x)<<" "<<x<<endl
ll mod=1e9+7;
template<typename t>
ll Max(ll a,ll b)
{
    return (a>b)?a:b;
    
}
ll Min(ll a,ll b)
{
    return (a>b)?b:a;
}
ll power(ll a,ll b)
{
    ll p=1;
    a=a%mod;
    b=b%mod;
    while(b)
    {
        if(b&1)
        {
            p=((p%mod)*(a%mod))%mod;
        }
        a=((a%mod)*(a%mod))%mod;
        b=(b/2);
    }
    return p%mod;
}
int main()
{
    int t;
    t=1;
  //  cin>>t;
    while(t--)
    {
        int x,n;
        cin>>x>>n;
        int a[n];
        bool visited[201]={false};
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            visited[a[i]]=true;
        }
        int A=0;
        while(A<=x)
        {
            int l=x-A;
            int r=x+A;
            if(visited[l]==false)
            {
                cout<<l<<endl;
                break;
            }
            else if(visited[r]==false)
            {
                cout<<r<<endl;
                break;
            }
            A++;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a = 0;
    int b = 0;
    int t = 0;
    int result = 0;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&t);


    for (int i = 1; i <= t ; i++) {
        if (i % a == 0) {
            result = result + b;
        }
    }
    
    printf("%d\n",result);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	long long int N, ans = 0;
	cin >> N;
	
	for (long long int i = 1; i * i + i < N; i++) {
		if ((N - i) % i == 0) {
			ans += (N - i) / i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <random>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;
using pci = std::pair<char, int>;

const long long INF = 1000000000000000001;
const long long _MOD_ = 1000000000000000009;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n, k;
	cin >> n >> k;
	pii* lr = new pii[n];
	rep(i, k) cin >> lr[i].first >> lr[i].second;

	ll* dp = new ll[n];
	dp[0] = 1;
	ll sum = 0;
	REP(i, 1, n) {
		rep(j, k) {
			if (i - lr[j].first < 0) continue;

			sum += dp[i - lr[j].first];
			sum %= MOD;
			if (i - lr[j].second - 1 >= 0) {
				sum -= dp[i - lr[j].second - 1];
				sum %= MOD;
				if (sum < 0) sum += MOD;
			}
		}

		dp[i] = sum;
	}

	cout << dp[n - 1] << "\n";

	return 0;
}


Measured memory_bytes: 6772
S = input()
p = 0
ans = 0
for s in S:
  if s == 'g':
    if p > 0:
      ans += 1
      p -= 1
    else:
      p += 1
  else:
    if p > 0:
      p -= 1
    else:
      ans -= 1
      p += 1
print(ans)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>

int n,x,y,hd[100001],cnt,d[100001],f[100001],t[200001],v[100001],num[21],fa[100001],mx;

struct node
{
	int to,next,ans;
}e[200001];

void addedge(int x,int y)
{
	e[++cnt].next=hd[x];
	hd[x]=cnt;
	e[cnt].to=y;
	e[cnt].ans=0;
}

int calc(int x) {return ((x-1)^1)+1;}
int getmax(int a,int b) {return a>b?a:b;}

void dfs(int x)
{
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]) fa[e[i].to]=x,dfs(e[i].to);
	memset(num,0,sizeof(num));
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]) 
			for (int j=0; j<21; j++)
				if ((f[e[i].to]>>j)&1) num[j]++;
	mx=-1;
	for (int i=20; i>=0; i--) 
		if (num[i]>1) {mx=i; break;}
	v[x]=mx+1;
	while (num[v[x]]) v[x]++;
	f[x]=(1<<v[x]);
	for (int i=v[x]+1; i<=20; i++)
		if (num[i]) f[x]|=(1<<i);
}

int main()
{
	scanf("%d",&n); cnt=0;
	memset(hd,0,sizeof(hd));
	memset(d,0,sizeof(d));
	for (int i=1; i<n; i++) 
		scanf("%d%d",&x,&y),addedge(x,y),addedge(y,x),d[x]++,d[y]++;
	memset(f,0,sizeof(f));
	memset(fa,0,sizeof(fa));
	dfs(1); mx=0;
	for (int i=1; i<=n; i++) mx=getmax(mx,v[i]);
	printf("%d\n",mx);
	return 0;
}

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

int main() {
        int a,b;
        string s;
	cin >> a >> b >> s;
	if (s[a] != '-') { cout << "No" << endl; return 0; }
	
	rep(i, a) if (!('0' <= s[i] && s[i] <= '9')) { cout << "No" << endl; return 0; }
	rep(i, b) if (!('0' <= s[a+1+i] && s[a+1+i] <= '9')) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<string>

using namespace std;

int a[200000],n,b;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)b^=a[i];
    for(int i=0;i<n;i++)cout<<(a[i]^b)<<"\n";
    return 0;
}

Measured memory_bytes: 4356
n = int(input())
if n >= 400 and n < 600:
  print(8)
elif n >= 600 and n < 800:
  print(7)
elif n >= 800 and n < 1000:
  print(6)
elif n >= 1000 and n < 1200:
  print(5)
elif n >= 1200 and n < 1400:
  print(4)
elif n >= 1400 and n < 1600:
  print(3)
elif n >= 1600 and n < 1800:
  print(2)
elif n >= 1800 and n < 2000:
  print(1)

Measured memory_bytes: 9192
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int food[] = new int[m];
		
		for(int i=0;i<n;i++) {
			int k = sc.nextInt();
			for(int j=0;j<k;j++) {
				food[sc.nextInt()-1] ++;
			}
		}
		sc.close();
		int count=0;
		for(int num : food) {
			if(num == n) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21972
s = list(input())

index = 0
ans = 0

if len(s) % 2 == 0:
    index = int(len(s) / 2)
else:
    index = int((len(s) // 2) + 1)

for i in range(index):
    if s[i] != s[-1-i]:
        ans += 1
    else:
        pass

print(ans)


Measured memory_bytes: 3060
#from collections import deque
#from math import gcd
#MOD = 10**9 + 7
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
ans = 0
#print(ans)
r = []
for k in range(N):
  r.append(tuple(map(int, input().split())))
r.sort(key = lambda x:x[0])
#print(r)
nowx = -1
lastx_min = r[0][0]
lastx_max = r[0][0]

miny = r[0][1]
maxy = r[0][1]
k = 0
while k < N:
  if nowx != r[k][0]:
    nowx = r[k][0]
    while r[k][0] == nowx:
      ans = max(ans, abs(miny - r[k][1]) + nowx - lastx_min, abs(maxy-r[k][1])+ nowx -lastx_max)
      if miny - (nowx - lastx_min) > r[k][1]:
        miny = r[k][1]
        lastx_min = nowx
      if maxy + (nowx - lastx_max) < r[k][1]:
        maxy = r[k][1]
        lastx_max = nowx
      k += 1
      if k == N:
        break

print(ans)

    

Measured memory_bytes: 106732
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

import bisect
from itertools import accumulate


n,m,k = readints()

a = readints()
b = readints()

c = [0] + list(accumulate(a))
d = [0] + list(accumulate(b))

ans = 0
for i in range(n+1):
    if c[i]>k:
        continue
    else:
        ans = max(ans,i+bisect.bisect_right(d,k-c[i])-1)

print(ans)








Measured memory_bytes: 129780
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll gcdll(ll a, ll b ){
    ll r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll lcmll(ll a, ll b ){
    if(a==0||b==0) return 0;
    return ((a/gcdll(a,b))*b);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    cout << lcmll(a,b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//useful library
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    int X;
    cin >> X;
    int long long t, f;
    int a = X / 500;
    int b = X % 500;
    int c = floor(b / 5);
    t = a * 1000;
    f = c * 5;
    cout << t + f << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	A := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scan(&A[i])
	}
	sort.Ints(A)
	ans := (A[2] - A[1]) + (A[1] - A[0])
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a, b, c, d;
	int x = 0,y = 0;
	cin>>a>>b>>c>>d;
	a--;
	x = a - a/c - a/d + a/(c/__gcd(c,d)*d);
	y = b - b/c - b/d + b/(c/__gcd(c,d)*d);
	
	// cout<<y<<" "<<x<<endl;
	cout<<y-x<<endl;
	return 0;
}

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

int N;

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&N);
	if(N%10==N/10%10||N/10%10==N/100%10||N/100%10==N/1000%10)
		puts("Bad");
	else puts("Good");
	return 0;
}

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

int main(){
   int N,D; cin >> N >> D;
   int min = 1;
   while(true){
    if(min * (2 * D + 1) >= N){
        cout << min << endl;
        break;
    }else{
        min ++;
    }
   }
}

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

using namespace std;
using ll = long long;

int main()
{
  int n, k;
  cin >> n >> k;
  if (n & 1)
  {
    n /= 2;
    n++;
    if (n >= k)
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  }
  else
  {
    n /= 2;
    if (n >= k)
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;


int main(){
  int x;
  cin >> x;
  if(x<1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string a;
	cin >> a;

	bool capable = false;

	if (a[0] == 'a' && a[1] == 'b' && a[2] == 'c') capable = true;
	else if (a[0] == 'a' && a[1] == 'c' && a[2] == 'b') capable = true;
	else if (a[0] == 'b' && a[1] == 'a' && a[2] == 'c') capable = true;
	else if (a[0] == 'b' && a[1] == 'c' && a[2] == 'a') capable = true;
	else if (a[0] == 'c' && a[1] == 'a' && a[2] == 'b') capable = true;
	else if (a[0] == 'c' && a[1] == 'b' && a[2] == 'a') capable = true;
	
	if (capable == true)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
 
def Main():
    n = I()
    h = list(IL())
    l = [1e9]*n
    l[0] = 0
    for i in range(1,n):
        l[i] = min(l[i],l[i-1]+abs(h[i-1]-h[i]))
        if 1<i:
            l[i] = min(l[i],l[i-2]+abs(h[i-2]-h[i]))
    print(l[n-1])
    return
 
if __name__=='__main__':
    Main()

Measured memory_bytes: 20568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		
		int score = 0;
		
		for(int i = 0; i < n; i++)
		{
			boolean p = s.charAt(i) == 'p';
			if(i%2==1)
			{
				if(!p)score++;
			}
			else if(p)score--;
		}
		System.out.println(score);
	}

}


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

int main(){
  long long A, B;
  int x=1, N;
  cin >> A >> B;
  N = min(A,B);
  
  for(int i=2; i<=N; i++){
    if(A%i == 0 && B%i == 0){
      A /= i;
      B /= i;
      x *= i;
      N /= i;
      i--;
    }
  }
  cout << A*B*x << endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string S;
	cin >> S;
	int Q;
	cin >> Q;
	bool rev=false;
	deque<char> d;
	rep(i,S.size()) d.push_back(S[i]);
	while(Q--){
		int T;
		cin >> T;
		if(T==1) rev=!rev;
		if(T==2){
			int F;
			char C;
			cin >> F >> C;
			F--;
			if(rev^F) d.push_back(C);
			else d.push_front(C);
		}
	}
	if(rev) reverse(d.begin(),d.end());
	rep(i,d.size()) cout << d[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
  #include <algorithm>
  #include <vector>
  #include <cmath>
#include <string>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <iomanip>
  #include <stack>
  #include <queue>
  #include <deque>
  using namespace std;
  vector <int> g[200005];
  bool used[200005];
  int dst[200005];
  void solve(int k){
      for (int i = 0; i <= 200005; i++) {
          dst[i] = -1;
          used[i]=0;
      }
      queue <int> q;
      q.push(k);
      used[k] = true;
      dst[k] = 0;
      while (!q.empty()) {
          int cur = q.front();
          q.pop();
          for (int neighbor: g[cur]) {
              if (!used[neighbor]) {
                  q.push(neighbor);
                  used[neighbor] = true;
                  dst[neighbor] = dst[cur] + 1;
              }
          }
      }
  }
    int main(){
        int n;
        cin>>n;
        for(int i=1;i<n;i++){
            int x,y;
            cin>>x>>y;
            g[x].push_back(y);
            g[y].push_back(x);
        }
        solve(1);
        int mx=0;
        int pos=1;
        for(int i=2;i<=n;i++){
            if(dst[i]>mx){
                mx=dst[i];
                pos=i;
            }
        }
        solve(pos);
        mx=0;
        pos=1;
        for(int i=1;i<=n;i++){
            if(dst[i]>mx){
                mx=dst[i];
                pos=i;
            }
        }
        if(mx%3==1){
            cout<<"Second";
            return 0;
        }
        cout<<"First";
        return 0;
}


Measured memory_bytes: 13812
n, k = gets.split.map(&:to_i)
last = 1
f = (1..n).map do |n|
  tmp = last * n
  last = tmp
  tmp
end.unshift(1)
(1..k).each { |i| puts (f[n-k+1] / (f[i] * f[n-k+1-i])) * (f[k-1] / (f[i-1] * f[k-1-(i-1)])) % 1000000007 }

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

typedef long long ll;
typedef pair<ll,ll> pll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
ll t;
map<ll,ll>res,mp;
vector<ll>v[2005];
void bfs(ll a,ll m)
{
    ll chk[2005]= {0},dis[2005]= {0};
    ll i,j;
    queue<ll>q;
    chk[a]=1;
    q.push(a);
    while(!q.empty())
    {
        ll b=q.front();
        q.pop();
        for(i=0; i<v[b].size(); i++)
        {
            ll d=v[b][i];
            if(chk[d])
                continue;
            q.push(d);
            chk[d]=1;
            dis[d]=dis[b]+1;
        }
    }
    for(i=a;i<=m;i++)
    {
        //cout<<dis[i]<<endl;
        res[dis[i]]++;
    }
    //dbg;
}

int main()
{
    int a,b,c,d,e,f,g,i,j;
    cin>>a>>b>>c;
    for(i=2; i<a; i++)
    {
        v[i].pb(i-1);
        v[i].pb(i+1);
    }
    v[1].pb(2);
    v[a].pb(a-1);
    v[b].pb(c);
    v[c].pb(b);
    for(i=1; i<a; i++)
    {
        mp[i]=1;
        bfs(i,a);


    }
    for(j=1; j<a; j++)
    {
        cout<<res[j]<<endl;
    }

}



Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    ll n,k,ans=0;
	string s;
	cin >> n;
	ll a[n];
	rep(i,n){
		cin >> a[i];
	}

	for(int i=n-1;i>0;i--){
		if(a[i-1]-a[i]>=2){
			cout << "No" << endl;
	 		return 0;
		}
		else if(a[i-1]>a[i]){
			a[i-1]--;
		}
	}

	// rep(i,n-1){
	// 	if(a[i]-a[i+1]>=2){
	// 		cout << "No" << endl;
	// 		return 0;
	// 	}
	// 	else if(a[i]>a[i+1]){
	// 		a[i]--;
	// 		ans++;
	// 	}
	// }

	// rep(i,n-1){
	// 	if(a[i]>a[i+1]){
	// 		cout << "No" << endl;
	// 		return 0;
	// 	}
	// }	

	cout << "Yes" << endl;


	// if(ans<=1){
	// 	cout << "Yes" << endl;
	// }
	// else{
	// 	cout << "No" << endl;
	// }
}

Measured memory_bytes: 1024
n = int(input())
mydic = {"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(n):
    mystr = input()
    mydic[mystr] += 1
print("AC x " + str(mydic["AC"]))
print("WA x " + str(mydic["WA"]))
print("TLE x " + str(mydic["TLE"]))
print("RE x " + str(mydic["RE"]))

Measured memory_bytes: 9000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		//System.out.println(x + " " + y + " " + z);
		int tmp = x;
		x = y;
		y = tmp;
		tmp = x;
		x = z;
		z = tmp;
		System.out.println(x + " " + y + " " + z);
		// TODO 自動生成されたメソッド・スタブ

	}

}


Measured memory_bytes: 21844
import math
import time
from collections import deque
from collections import defaultdict
from copy import deepcopy

mod = 10 ** 9 + 7
t = time.time()


def inv(n, mod):
    return power(n, mod-2)

def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return ((power(n, p//2) % mod) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod

def main():
    X, Y = iip()
    aa = (int(-X) + int(2*Y)) // 3
    bb = (int(-Y) + int(2*X)) // 3
    if (int(-X) + int(2*Y)) % 3 != 0 or  (int(-Y) + int(2*X)) % 3 != 0:
        print(0)
        exit()

    if X > 2*Y or Y > 2*X:
        print(0)
        exit()

    a = min(aa, bb)
    b = max(aa, bb)

    npr = 1
    bunbo = 1
    for i in range(1, a+1):
        npr *= (i+b)
        npr = npr % mod

        bunbo *= i
        bunbo = bunbo % mod

    ans = npr * inv(bunbo, mod) % mod

    print(ans)



main()

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[N], b[N];
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    int ans = 0;
    for(int v = (1 << 28); v != 0; v >>= 1) {
        rep(i, N) a[i] &= (v*2-1);
        rep(i, N) b[i] &= (v*2-1);
        sort(a, a+N); sort(b, b+N);
        int t = 0;
        for(int i = N - 1, j = 0, k = 0, l = 0; i >= 0; i--) {
            while(j < N && a[i] + b[j] < v) j++;
            if (i == N - 1 ) k = j;
            while(k < N && a[i] + b[k] < 2*v) k++;
            if (i == N - 1 ) l = k;
            while(l < N && a[i] + b[l] < 3*v) l++;
            /*
            if (!(j == k && k == l)) {
                cout << v << ":" << j << " " << k << " " << l << endl;
            }
            */
            t += k-j + N-l;
            t &= 1;
        }
        if (t) ans |= v;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
void work() {
	LL x,y;
	scanf("%lld%lld",&x,&y);
	int ans=0;
	while(x<=y) ans++,x*=2;
	printf("%d\n",ans);
	return ;
}
int main() {
	//freopen("in","r",stdin);
	work();
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size()<=k){
        cout<<s<<endl;
    }else{
        rep(i,k){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;
ll fact(ll n)
{
ll    res=1;
    for(int i = 1; i <= n;i++){
    res = res * i ;
}
return res;
}



int main()
{   IOS;
    int n; cin >> n; vector<ll> A(n+1,0),B(n,0); ll a,b;
    for (int i=0;i<=n;i++)
    {
        cin >> a;
        A.push_back(a);

    }
    for(int i=0;i<n;i++)
    {
        cin >> b;
        B.push_back(b);
    }
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    ll res=0;
    for(int i=0;i<n;i++)
    {
        if(B[i]>=A[i])
            {
                B[i]=B[i]-A[i];
                res+=A[i];
                A[i]=0;
            }
        else if (B[i]<A[i])
        {   res+=B[i];
            A[i]-=B[i];
            B[i]=0;

        }
        if(B[i]<A[i+1])
        {
            res+=B[i];
            A[i+1]=A[i+1]-B[i];
        }

        else if(B[i]>=A[i+1])
            {res+=A[i+1];
            A[i+1]=0;}
    }
        cout << res;




    cout.precision(30);
    return 0;
}


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

int g(int x, int y, int z){
  int k = x + y + z;
 return k*k-x*y-y*z-z*x;
}

int main(void){
  int N;
  cin>>N;
  vector<int> ans(N+1,0);
  int a=6;
  int n=5;
  int k=3;
 for(int x =1;x<=100;x++){
   for(int y=1;y<=100;y++){
     for(int z=1;z<=100;z++){
       int t = g(x,y,z);
       if(t<=N)ans[t]++;
     }
   }
 }
  for(int i=1;i<=N;i++){
    cout<<ans[i]<<endl;}
  return 0; 
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

const ll L = 1000000000;

int main(){

    ll s;
    cin >> s;
    if(s < 10000){
        cout << 0 << " " << 0 << " ";
        cout << s << " " << 0 << " ";
        cout << 0 << " " << 1 << endl;
        return 0;
    }
    ll r = ceil(sqrt(s));
    ll red = r * r - s;
    ll x1 = 0, y1 = 0;
    ll x2 = r, y2 = -1;
    ll x3 = -1, y3 = r;
    for(ll i = 2; i * i <= red; i++){
        if(red % i == 0 && i <= L && red / i <= L){
            y2 = i;
            x3 = red / i;
            break;
        }
    }
    if(y2 < 0){
        y2 = red;
        x3 = 1;
    }
    // if(x1 > L)cout << "x1" << endl;
    // if(y1 > L)cout << "y1" << endl;
    // if(x2 > L)cout << "x2" << endl;
    // if(y2 > L)cout << "y2" << endl;
    // if(x3 > L)cout << "x3" << endl;
    // if(y3 > L)cout << "y3" << endl;
    cout << x1 << " " << y1 << " ";
    cout << x2 << " " << y2 << " ";
    cout << x3 << " " << y3 << endl;



    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(abs,x))
ans = float("inf")

for i in range(n-k+1):
    if 0 < x[i] * x[i+k-1]:
        cost = max(y[i],y[i+k-1])
        
    else:
        cost = y[i] + y[i+k-1] + min(-x[i],x[i+k-1])
        
    ans = min(ans,cost)
    
print(ans)

Measured memory_bytes: 19936
#include <iostream>

using namespace std;

int main() {
    int i, a, b, c, count;

    cin >> a >> b >> c;

    for (i = a; i <= b; i++) {
        if (c % i == 0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int m=1<<(s[1]+s[2]+s[3]);
		long ans=0;
		long[][] dp=new long[s[0]+1][],dp2=new long[s[0]+1][];
		dp[0]=new long[m];
		dp2[0]=new long[m];
		dp[0][0]=1;
		for(int i=0;i<s[0];i++){
			dp[i+1]=new long[m];
			dp2[i+1]=new long[m];
			for(int j=0;j<m;j++){
				if(dp[i][j]+dp2[i][j]==0){continue;}
				for(int k=1;k<=10;k++){
					int q=((j<<k)|(1<<(k-1)))&(m-1);
					if(((q&(1<<(s[3]-1)))!=0&&(q&(1<<(s[3]+s[2]-1)))!=0&&(q&(1<<(s[3]+s[2]+s[1]-1)))!=0)){
						dp2[i+1][q]=(dp2[i+1][q]+dp[i][j])%mod;
					}
					else{
						dp[i+1][q]=(dp[i+1][q]+dp[i][j])%mod;
					}
					dp2[i+1][q]=(dp2[i+1][q]+dp2[i][j])%mod;
				}
			}
		}
		for(int j=0;j<m;j++){ans=(ans+dp2[s[0]][j])%mod;}
		Console.WriteLine(ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

int main(void) {
    int n, t, a;
    cin >> n >> t >> a;
    double mi = 1e9;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        int h;
        cin >> h;
        double th = abs(t - a - h * 0.006);
        if (th < mi) {
            mi = th;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  //情報取得
  int N;
  cin>>N;
  vector<int>problem(N);
  for(int i=0;i<N;i++){
   cin>>problem.at(i); 
  }
  int M;
  cin>>M;
  vector<vector<int>>drink(2,vector<int>(M));
  for(int i=0;i<M;i++){
   cin>>drink.at(0).at(i)>>drink.at(1).at(i); 
  }
  //計算結果出力
  for(int i=0;i<M;i++){
    int ans=0;
    for(int j=0;j<N;j++){
       if(drink.at(0).at(i)-1==j){
        ans+=drink.at(1).at(i);
       }else{
        ans+=problem.at(j);
       }
     }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3640