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

int main(){
    long long X;
    cin >> X;
    for(long long i=-150;i<150;i++){
        for(long long j=-150;j<150;j++){
            if(i*i*i*i*i-j*j*j*j*j==X){
            cout << i << " " << j << endl;
            return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define REP(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  int a,p;
  cin>>a>>p;
  cout<<(a*3+p)/2<<endl;
return 0;
}

Measured memory_bytes: 3588
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl: return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    from itertools import accumulate
    import sys

    input = sys.stdin.readline

    MX = 10 ** 5

    s = Sieve(MX)

    like2017 = [0] * (MX + 1)
    for x in range(1, MX + 1, 2):
        if s.is_prime(x) and s.is_prime((x + 1) // 2):
            like2017[x] = 1

    *acc, = accumulate(like2017)

    Q = int(input())

    ans = []
    for _ in range(Q):
        left, right = map(int, input().split())
        res = acc[right] - acc[left - 1]
        ans.append(res)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 14368
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
vector<char> v;
string n="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
string k=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string m[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
void F1(char z){
	int a,b=32;
	rep(i,32)if(n[i]==z)a=i;
	rep(i,5){
		v.push_back('0'+(a%b>=b/2));
		b/=2;if(b==1)break;
	}
}
int main(){
	string s,r;
	while(getline(cin,s)){
	r="";v.clear();
	rep(i,s.size())F1(s[i]);
	rep(i,v.size()){
		r.push_back(v[i]);
		rep(j,32){if(m[j]==r){
			cout<<k[j];r="";
		}}
	}cout<<endl;}
	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<string.h>

int main(void){
  int i, count = 0;
  char s[200010],t[200010];
  scanf("%s",s);
  scanf("%s",t);
  int n = strlen(s);
  for(i=0;i<n;i++){
    if(s[i] != t[i]){
      count++;
    }
  }
  printf("%d", count);
  
  return 0;
}

Measured memory_bytes: 2064
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {
    int point_num = 0;
    
    cin >> point_num;
    
    int T;
    int A;
    cin >> T;
    cin >> A;
    
    int heights[point_num];
    for (int i = 0; i < point_num; i++) {
        cin >> heights[i];
    }
    
    float max = 21474836471.0f;
    int min_index = 0;
    for (int i = 0; i < point_num; i++) {
        float result = fabs((float)(T - heights[i] * 0.006f) - A);
        if (max > result) {
            max = result;
            min_index = (i + 1);
        }
    }
    
    cout << min_index << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int M,D;
  	int d1,d2;
  	int count = 0;
  
  	scanf("%d %d",&M,&D);
  	
  		for(int i=22;i<=D;i++){
    		d1 = i/10;
          	d2 = i%10;
            
          	if(d1 < 2 || d2 < 2){
            
            }else if(d1*d2 <= M){
              count++;
            }
          
    	}
  
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void) {
	int N,x,y,b,p,sum,sum2;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d%d%d%d", &x, &y,&b,&p);
		sum = (x*b + y*p);
		if (b >= 5 && p >= 2)sum *= 0.8;
		else {
			if (b <= 4 && p >= 2) {
				sum2 = (x*5 + y*p)*0.8;
			}
			else if (b >= 5 && p < 2) {
				sum2 = (x * b + y*2)*0.8;
			}else sum2= (x * 5 + y * 2)*0.8;
			if (sum > sum2)sum = sum2;
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>

using namespace std;

# define REP(i,n) for(int i=0; i<n; i++)


long long int fact(long long int number){
//	cout << "fact(" << number << ")";
	if(number==1){
		return 1;
	}
	return (number*(fact(number-1)))%1000000007;
}

int main()
{
	long long int n,m;
	cin >> n >> m;
	
//	cout << "n! : " << fact(n) << " m! : " << fact(m) << endl;
	
	long long int d = n-m;
	
	if(d>1 || d<-1){
		cout << "0" << endl;
		return 0;
	}

	long long int ans;
	
	if(d==1 || d==-1){
		ans = (fact(n)*fact(m))%1000000007;
	}else{
		ans = ((fact(n)*fact(m))*2)%1000000007;
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
ll nCr[51][51];
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  vector<ll> v(N);
  REP(i,N) cin >> v[i];
  sort(v.begin(),v.end(),greater<ll>());
  double ave = 0;
  REP(i,A) ave += v[i];
  ave /= A;
  printf("%.10f\n",ave);
  int l = A-1;
  int r = A-1;
  while(l > 0 && v[l-1] == v[l]) l--;
  while(r < N-1 && v[r] == v[r+1]) r++;
  REPS(i,50){
    nCr[i][0] = 1;
    nCr[i][i] = 1;
  }
  FOR(i,2,51){
    FOR(j,1,i){
      nCr[i][j] = nCr[i-1][j-1] + nCr[i-1][j];
    }
  }
  ll ans = 0;
  if(v[A-1] == v[0]){
    for(int i = A-l;i <= min(r-l+1,B-l);i++){
      ans += nCr[r-l+1][i];
    }
  }
  else{
    ans = nCr[r-l+1][A-l];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

#define error 1e-10

int main(){
	double x[5],y[5];
	int n;
	double parallel1,parallel2;

	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=1;j<5;j++)
			cin>> x[j]>> y[j];
		parallel1=(y[2]-y[1])/(x[2]-x[1]);
		parallel2=(y[4]-y[3])/(x[4]-x[3]);
		if(x[2]-x[1] == 0 && x[4]-x[3] == 0)  cout<<"YES"<<endl;
		else (fabs(parallel1-parallel2)<error ) ? cout<<"YES"<<endl : cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

int dp[MAXN];
int h[MAXN];
int32_t main(){
	fastio;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		dp[i] = 1e18;
		cin>>h[i];
	}
	dp[1]=0;
	dp[0] = 1e18;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=2;j++){
			if(i-j>=1){
				dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]));
			}
		}
	}
	cout<< dp[n]<<endl;
	
	
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	int n = s.size();
	ll ans = 0;
	int as = 0;
	for(int i = 0 ; i + 1 < n ; i++){
		if(s[i] == 'A'){
			as = as + 1;
		}
		else if(s[i] == 'B' && s[i + 1] == 'C'){
			ans += as;
			i++;
		}
		else as = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
using namespace std;
using ll = long long;

template<typename T, class F = function<T(const T&, const T&)>>
class SegmentTree {
  public:
    SegmentTree(int n_, T i, F f, F g) : I(i), get(f), upd(g) {
      for(n = 1; n < n_; n *= 2);
      data.assign(n*2 - 1, I);
    }

    void update(int i, T x){
      i += n - 1;
      data[i] = upd(data[i], x);
      while(i){
        i = (i-1) / 2;
        data[i] = get(data[i*2 + 1], data[i*2 + 2]);
      }
    }
    // [a,b)
    T query(int a, int b){
      return query(a, b, 0, 0, n);
    }

  private:
    int n;
    vector<T> data;
    T I;
    F get, upd;

    T query(int a, int b, int i, int l, int r){
      if(b<=l || r<=a) return I;
      if(a<=l && r<=b) return data[i];
      int vl = query(a, b, i*2+1, l, (l+r)/2);
      int vr = query(a, b, i*2+2, (l+r)/2, r);
      return get(vl, vr);
    }
};

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  ll n, m, a, b; cin >> n >> m;

  vector<pair<ll, ll>> ps;
  for(int i = 0; i < n; ++i) {
    cin >> a >> b;
    ps.emplace_back(b, a);
  }
  sort(ps.rbegin(), ps.rend());

  ll ans = 0;
  SegmentTree<int> st(m+1, -1, [](int i, int j){ return max(i, j); }, [](int i, int j){ return j; });
  for(int i = 0; i <= m; ++i) st.update(i, i);
  for(int i = 0; i < n; ++i) {
    b = ps[i].first, a = ps[i].second;
    int res = st.query(0, m - a + 1);
    if(res != -1) {
      st.update(res, -1);
      ans += b;
    }
  }
  cout << ans;
  return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n;
    cin>>n;
    rep(i,1,n+1){
        if(int(i*1.08)==n){
  //      cout<<int(i*1.08)<<" "<<i*1.08<<endl;
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

typedef long long ll;

int main(){
    ll N, X;
    ll ans = 0;
    cin >> N >> X;
    ans = N;
    ll Y = N-X;
    if(X < Y) swap(X, Y);
    while(Y != 0){
        ans += (X/Y)*Y*2;
        ll tmp = Y;
        Y = X%Y;
        X = tmp;
    }
    cout << ans - X << endl;
}

Measured memory_bytes: 256
n, a, b, c, d = gets.split.map(&:to_i)
ary = gets.chomp.chars

needChange = false

if a > b && c < d || a < b && c > d
  needChange = true
  for i in [a, b].max - 2 .. [c, d].min - 2
    if [ary[i], ary[i + 1], ary[i + 2]] == ['.', '.', '.']
      needChange = false
    end
  end
end

if needChange == true
  puts :No
  exit
end

for i in [a, b].min - 1 .. [c, d].max - 1
  if [ary[i], ary[i + 1]] == ['#', '#']
    if a < i && i < c || b < i && i < d
      puts :No
      exit
    end
  end
end

puts :Yes


Measured memory_bytes: 16764
<?php
$n=trim(fgets(STDIN));
$max=-1;
$max_i=-1;
$next=-1;
$next_i=-1;
$i=0;
while($i<$n){
  $a=trim(fgets(STDIN));
  if($max<=$a){
    $next=$max;
    $next_i=$max_i;
    $max=$a;
    $max_i=$i;
  }elseif($next<$a){
    $next=$a;
    $next_i=$i;
  }
  ++$i;
}
if($max==$next){
  echo str_repeat($max . PHP_EOL,$n);
}else{
  echo str_repeat($max . PHP_EOL,$max_i);
  echo $next . PHP_EOL;
  echo str_repeat($max . PHP_EOL,$n-$max_i-1);
}

Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int n,l;
  cin>>n>>l;
  vector<string> mojis(n);
  rep(i,n) cin>>mojis[i];
  //辞書順にnこの文字列を並べ、それを順に結合すればよい
  sort(mojis.begin(),mojis.end());
  rep(i,n) cout<<mojis[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int x, y;
	while ((x != 0)||(y != 0)) {
		cin >> x >> y;
		if ((x != 0)||(y != 0))
			if (x<y) {
				cout << x << " " << y << endl;
			} else cout << y << " " << x << endl;
	}
}


Measured memory_bytes: 2984
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif
    
    int K;
    cin >> K;

    int a = 7 % K;
    rep1(i, K){
        if(a % K == 0){
            cout << i << '\n';
            return 0;
        }
        ((a *= 10) += 7) %= K;
    }

    cout << -1 << '\n';

    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] parent = new int[n + 1];
    int[] size = new int[n + 1];
    for (int i = 1; i <= n; i++) {
      parent[i] = i;
      size[i] = 1;
    }
    for (int i = 0; i < m; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      union(parent, size, a, b);
    }
	int maxSize = 0;
    for (int i = 1; i <= n; i++) {
      maxSize = Math.max(maxSize, size[i]);
    }
    System.out.println(maxSize);
  }

  private static int find(int[] parent, int node) {
    int root = node;
    while (root != parent[root]) {
      root = parent[root];
    }
    int currNode = node;
    while (currNode != root) {
      int nextNode = parent[currNode];
      parent[currNode] = root;
      currNode = nextNode;
    }
    return root;
  }

  private static void union(int[] parent, int[] size, int node1, int node2) {
  	int root1 = find(parent, node1);
    int root2 = find(parent, node2);
    if (root1 != root2) {
      if (size[root1] < size[root2]) {
        parent[root1] = root2;
        size[root2] += size[root1];
      } else {
        parent[root2] = root1;
        size[root1] += size[root2];
      }
    }
  }
}

Measured memory_bytes: 61636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll n;
  cin >> n;
  vl an(n + 1);
  rep(i, n + 1) cin >> an[i];
  combination comb(1e5 + 10);
  vl p(n + 1, -1);
  vl x;
  rep(i, n + 1) {
    if(p[an[i]] != -1) {
      x.push_back(p[an[i]]);
      x.push_back(i);
    } else
      p[an[i]] = i;
  }
  ll a = x[0];
  ll b = x[1] - x[0] - 1;
  ll c = n - x[1];
  rep2(k, 1, n + 2) {
    mint na = comb(a, k - 1);
    mint nb = comb(b, k - 1);
    mint nc = comb(c, k - 1);
    mint nab = comb(a + b, k - 1) - na - nb;
    mint nbc = comb(b + c, k - 1) - nb - nc;
    mint nca = comb(c + a, k - 1) - nc - na;
    mint nabc = comb(a + b + c, k - 1) - nab - nbc - nca - na - nb - nc;
    mint xx = comb(a + b + c, k - 2);
    mint abc = comb(a + b + c, k);
    mint ans = na + nb * 2 + nc + nab * 2 + nbc * 2 + nca + nabc * 2 + xx + abc;
    cout << ans << '\n';
  }
}

Measured memory_bytes: 4352
#include<iostream>

int memo[12][1024];

void dfs( int d, int bit, int sum )
{
	++memo[d][sum];
	for( int i = 0; i != 10; ++i )
	{
		if( bit & ( 1 << i ) )
			dfs( d + 1, bit & ~( 1 << i ), sum + ( d + 1 ) * i );
	}

	return;
}

int main()
{
	int n, s;
	dfs( 0, ( 1 << 10 ) - 1, 0 );
	while( std::cin >> n >> s )
		std::cout << ( s > 1023 ? 0 : memo[n][s] ) << std::endl;

	return 0;
}

Measured memory_bytes: 1200
//52
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

struct S{
  int c,v,d;
  bool operator<(S a)const{
    return d>a.d;
  }
};

struct E{
  int t,d,e;
};

int main(){
  for(int n,m,l;cin>>n>>m>>l,n|m|l;){
    vector<E> e[101];
    while(m--){
      int a,b,d,ee;
      cin>>a>>b>>d>>ee;
      E x={b,d,ee};
      e[a].push_back(x);
      x.t=a;
      e[b].push_back(x);
    }
    priority_queue<S> que;
    S is={l,1,0};
    que.push(is);
    bool p[101][101]={{}};
    for(;;){
      S c=que.top();
      if(c.v==n)break;
      que.pop();
      if(p[c.v][c.c]++)continue;
      for(int i=0;i<e[c.v].size();i++){
	S n={c.c,e[c.v][i].t,c.d+e[c.v][i].e};
	que.push(n);
	if(c.c>=e[c.v][i].d){
	  S n={c.c-e[c.v][i].d,e[c.v][i].t,c.d};
	  que.push(n);
	}
      }
    }
    cout<<que.top().d<<endl;
  }
  return 0;
}

Measured memory_bytes: 1888
#include <stdio.h>

typedef struct {
	short surf[6];
	short top;
	short top_add;
	short front;
	short front_add;
} dice;

int main(void){

	dice dice1 = {0,0};

	short q;
	register short i,j;

	for(i = 0;i < 6;i++){
		scanf("%d",&dice1.surf[i]);
	}
	scanf("%d",&q);
	for(i = 0;i < q;i++){
		scanf("%d",&dice1.top);
		for(j = 0;j < 6;j++){
			if(dice1.top == dice1.surf[j]){
				dice1.top_add = j;
				break;
			}
		}
		scanf("%d",&dice1.front);
		for(j = 0;j < 6;j++){
			if(dice1.front == dice1.surf[j]){
				dice1.front_add = j;
				break;
			}
		}
		
		switch(dice1.top_add){
			case 0:
				switch(dice1.front_add){
					case 1:
						printf("%d\n",dice1.surf[2]);
						break;
					case 2:
						printf("%d\n",dice1.surf[4]);
						break;
					case 3:
						printf("%d\n",dice1.surf[1]);
						break;
					case 4:
						printf("%d\n",dice1.surf[3]);
						break;
					default:
						break;
				}
				break;
			case 1:
				switch(dice1.front_add){
					case 0:
						printf("%d\n",dice1.surf[3]);
						break;
					case 2:
						printf("%d\n",dice1.surf[0]);
						break;
					case 3:
						printf("%d\n",dice1.surf[5]);
						break;
					case 5:
						printf("%d\n",dice1.surf[2]);
						break;
					default:
						break;
				}
				break;
			case 2:
				switch(dice1.front_add){
					case 0:
						printf("%d\n",dice1.surf[1]);
						break;
					case 1:
						printf("%d\n",dice1.surf[5]);
						break;
					case 4:
						printf("%d\n",dice1.surf[0]);
						break;
					case 5:
						printf("%d\n",dice1.surf[4]);
						break;
					default:
						break;
				}
				break;
			case 3:
				switch(dice1.front_add){
					case 0:
						printf("%d\n",dice1.surf[4]);
						break;
					case 1:
						printf("%d\n",dice1.surf[0]);
						break;
					case 4:
						printf("%d\n",dice1.surf[5]);
						break;
					case 5:
						printf("%d\n",dice1.surf[1]);
						break;
					default:
						break;
				}
				break;
			case 4:
				switch(dice1.front_add){
					case 0:
						printf("%d\n",dice1.surf[2]);
						break;
					case 2:
						printf("%d\n",dice1.surf[5]);
						break;
					case 3:
						printf("%d\n",dice1.surf[0]);
						break;
					case 5:
						printf("%d\n",dice1.surf[3]);
						break;
					default:
						break;
				}
				break;
			case 5:
				switch(dice1.front_add){
					case 1:
						printf("%d\n",dice1.surf[3]);
						break;
					case 2:
						printf("%d\n",dice1.surf[1]);
						break;
					case 3:
						printf("%d\n",dice1.surf[4]);
						break;
					case 4:
						printf("%d\n",dice1.surf[2]);
						break;
					default:
						break;
				}
				break;
			default:
				break;
		}
	}

	return 0;
}

Measured memory_bytes: 596
import math
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
a,b=map(int,input().split())
hcf=gcd(a,b)
l=int(math.sqrt(hcf))
divset=set()
for i in range(1,l+1):
    if hcf%i==0:
        divset.add(i)
        divset.add(hcf//i)
divset.remove(1)
d=list(divset)
d.sort()
for i in range(1,len(d)):
    for j in range(i):
        if d[i]%d[j]==0:
            divset.remove(d[i])
            break
print(len(divset)+1)
        

Measured memory_bytes: 41692
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string N;
  std::cin >> N;
  std::cout << (N.find('7') != std::string::npos ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {

	set<int> s;

	

	REP(i, 3) {
		int a;
		cin >> a;

		s.insert(a);
	}

	cout << ((s.size() == 2) ? "Yes" : "No") << endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define cy cout<<"Yes"
#define cn cout<<"No"
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//const ll mod=998244353;
const ll mod=1e9+7;
const ll MAX=300000;

//////////////////////////////////////

int main(){

    ll n,d;
    cin>>n>>d;
    int ans=0;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        if(a*a+b*b<=d*d)ans++;

    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  int x, y;
  cin >> x >> y;
  for(int c = 0; c <= x; c++){
    int t = x - c;
    int asi = c * 2 + t * 4;
    if(asi == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define test int t;cin>>t; while(t--)
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
vi b_v;void bin(unsigned int n) { if (n > 1) bin(n>>1); b_v.pb(n & 1); }
int isPowerof2(int x) { return (x && !(x & x-1)); }

int dp[100+1][100000+1];

int32_t main(){
    boost;osit;
    int n,W;
    cin>>n>>W;
    int v[n+1],w[n+1];
    rep(i,1,n+1){
        cin>>w[i]>>v[i];
    }
    rep(i,1,n+1){
        rep(j,1,W+1){
            if(j>=w[i]){
                dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 78336
from collections import defaultdict as dd
N = int(input())
a = list(map(int, input().split()))
D = dd(int)
for i in range(N):
  D[a[i]] += 1
ans = 0
for i in D:
  if D[i] < i:
    ans += D[i]
  else:
    ans += D[i] - i
print (ans)

Measured memory_bytes: 18664
s=gets.chomp
n=s.size

x, y=-2, -2

i=0
while i+1<n do
    x, y=i, i+1 if s[i]==s[i+1]
    i+=1
end

i=0
while i+2<n do
    x, y=i, i+2 if s[i]==s[i+2]
    i+=1
end

puts "#{x+1} #{y+1}"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
分岐の処理をどうするか
x軸y軸それぞれにプラマイ自由にできるか
最初のTまでだけ固定
わけられた数字のパーツあわせてxyにできるかどうか

2 3 5 7
8をつくる
せいぜい8000まで
mapとか8000*8000

ああ、いけたけど、DPでいいのか
*/
int main(){
  string S; cin>>S;
  ll X,Y; cin>>X>>Y;
  ll ssz=S.size(), i=0, tmp=0;
  vector<ll> A(0,0), B(0,0);
  vector<vector<bool>> DP1(8010,vector<bool>(8010,false)),DP2(8010,vector<bool>(8010,false));
  DP1[0][0]=true;
  DP2[0][0]=true;
  bool row=false;
  while(S[i]=='F' && i<ssz){
    X--;
    i++;
  }
  i++;
  while(i<ssz){
    if(S[i]=='T'){
      if(tmp>0) (row)?A.emplace_back(tmp):B.emplace_back(tmp);   
      row=(row)?false:true;
      tmp=0;
    }
    else tmp++;
    i++;
  }
  if(tmp>0) (row)?A.emplace_back(tmp):B.emplace_back(tmp);    
  ll asz=A.size(), bsz=B.size();
//cout<<"a:"<<asz<<" b:"<<bsz<<endl;  
  for(i=0; i<asz; i++){
    for(ll j=0; j<=8000; j++){
      if(DP1[i][j]){
        ll n=j+A[i], m=abs(j-A[i]);
        DP1[i+1][n]=true;
        DP1[i+1][m]=true;
      }
    }
  }
  for(i=0; i<bsz; i++){
    for(ll j=0; j<=8000; j++){
      if(DP2[i][j]){
        ll n=j+B[i], m=abs(j-B[i]);
        DP2[i+1][n]=true;
        DP2[i+1][m]=true;
      }
    }
  }
  X=abs(X),Y=abs(Y);
  if(DP1[asz][X] && DP2[bsz][Y]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
//cout<<endl;
//for(auto v:A)cout<<v<<" ";
//cout<<endl;
//for(auto v:B)cout<<v<<" ";

}

Measured memory_bytes: 17024
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(2 * N);
    rep(i, 2 * N) cin >> A[i];

    constexpr int Amax = 50;
    vv<int> dp = vvec(1 << N, Amax + 1, INF);
    dp[0][0] = 0;
    rep(bit, (1 << N) - 1) {
        int bcnt = 0;
        rep(b, N) bcnt += bit >> b & 1;

        int preb = 0;
        rep(b, N) {
            if (bit >> b & 1) {
                preb++;
                continue;
            }
            int t = A[b + ((b - bcnt) % 2 ? N : 0)];
            rep(s, Amax + 1) {
                if (t >= s) {
                    dp[bit | (1 << b)][t] = min(dp[bit | (1 << b)][t], dp[bit][s] + b - preb);
                }
                else break;
            }
        }
    }

    int ans = INF;
    rep(s, Amax + 1) ans = min(ans, dp[(1 << N) - 1][s]);
    write(ans == INF ? -1 : ans);
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

pll add(pll l, pll r) {
	return { l.first + r.first, l.second + r.second };
}
pll sub(pll l, pll r) {
	return { l.first - r.first, l.second - r.second };
}

int solve(set<pair<ll, ll>> st, pair<ll, ll> way) {
	int res = 0;
	while (!st.empty()) {
		auto base = *st.begin();
		st.erase(base);

		auto now = base;
		while (true) {
			now = sub(now, way);
			if (st.find(now) != st.end()) {
				st.erase(now);
			}
			else break;
		}
		now = base;
		while (true) {
			now = add(now, way);
			if (st.find(now) != st.end()) {
				st.erase(now);
			}
			else break;
		}

		res++;
	}
	return res;
}

int main()
{
	int N;
	cin >> N;
	vector<pair<ll, ll>> xy(N);
	REP(i, N)cin >> xy[i].first >> xy[i].second;

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

	set<pair<ll, ll>> cands;
	REP(i, N)REP(j, i) {
		cands.insert(sub(xy[i], xy[j]));
	}

	set<pair<ll, ll>> st;
	for (auto p : xy)st.insert(p);

	int res = INF;
	for (auto cand : cands) {
		res = min(res, solve(st, cand));
	}
	cout << res << endl;
	return 0;
}


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

int main () {
	int r;
	cin >> r;
	if (r<1200){
		cout << "ABC" <<endl;
	}
	if (r<2800&&r>=1200){
		cout << "ARC" << endl;
	}
	if (r>=2800&&r<=4208) {
		cout << "AGC" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int N, f[10005];
int main() {
    scanf("%d", &N);
    f[0] = 1;
    for(int i=1, v; i<=N; ++i) {
	scanf("%d", &v);
	for(int j=10000; j>=v; --j)
	    if(f[j-v]) f[j] = true;
    }
    for(int i=10000; ~i; --i) {
	if(f[i] && (i%10 || !i)) {
	    printf("%d\n", i);
	    break;
	}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
 
typedef long long ll;
#define INF 1000000000000000ll
 
ll calc(vector<ll>& s, vector<ll>& t,ll x);
 
ll A, B, Q;
vector<ll> si, ti, xi;
 
int main() {
  cin >> A >> B >> Q;
  si = vector<ll>(A+2);
  ti = vector<ll>(B+2);
  xi = vector<ll>(Q);
  si[0] = - INF;
  si[A+1] = INF;
  ti[0] = - INF;
  ti[B+1] = INF;
  for (ll i=0;i<A;i++){
    cin >> si[i+1];
  }
  for (ll i=0;i<B;i++){
    cin >> ti[i+1];
  }
  for (ll i=0;i<Q;i++){
    cin >> xi[i];
    cout << calc(si, ti, xi[i]) << endl;
  }
}
 

ll calc(vector<ll>& s, vector<ll>& t, ll x) {
 
	ll ans = LLONG_MAX;
 
	for (int i = 0; i < 2; i++) {
		vector<ll> &a = (i == 0) ? s : t;
		vector<ll> &b = (i == 0) ? t : s;
 
		for (int j = 0; j < 2; j++) {
			int apos = lower_bound(a.begin(), a.end(), x) - a.begin() - j;
			ll ax = a[apos];
			for (int k = 0; k < 2; k++) {
				int bpos = lower_bound(b.begin(), b.end(), x) - b.begin() - k;
				ll bx = b[bpos];
				ll d = max(x - ax, ax - x) + max(ax - bx, bx - ax);
				if (ans > d) { ans = d; }
			}
		}
	}
	return ans;
 
}


Measured memory_bytes: 3712
N, Q = map(int, input().split())
S = input()
tmp = [0] * (N+1)

for i in range(N):
  w = 1 if S[i:i+2] == 'AC' else 0
  tmp[i+1] = tmp[i] + w
  
for _ in range(Q):
  l, r = map(int, input().split())
  print(tmp[r-1] - tmp[l-1])

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

int main(){
    int k, n;
    cin>>k>>n;
    int a[n];
    int i,j;
    for(i=0;i<n;i++) cin>>a[i];
    int d[n];
    for(i = 0;i<n-1;i++) d[i] = a[i+1] - a[i];
    d[n-1] = k-a[n-1]+a[0];
    int max_i = 0;
    for(i = 0;i<n;i++) if(d[i]> d[max_i]) max_i = i;
    cout<<k-d[max_i]<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>

int main(){
   std::string S;
   std::cin >> S;

   const int n = S.size();
   bool flag = true;
   for(int i=0; i<n; ++i){
      if(i%2==1 && S[i]=='R') {
	 std::cout << "No" << std::endl;
	 return 0;
      }else if(i%2==0 && S[i]=='L') {
	 std::cout << "No" << std::endl;
	 return 0;
      }
   }
   std::cout << "Yes" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,m;
ll k;
int pos[N];
int hd[N],cnt;
int to[N][70];
bool vis[N];
int id[N],th[N];
int tot;
ll p[N];
int cha[N];
int ans[N];
int go[N];
int main()
{
	scanf("%d",&n);
	int las=0;
	for(int i=1;i<=n;i++) scanf("%lld",&p[i]),cha[i]=p[i]-las,las=p[i],pos[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;i++){
		scanf("%d",&go[i]);
	}
	for(int i=1;i<=m;i++){
		swap(pos[go[i]],pos[go[i]+1]);
	}
	for(int i=1;i<=n;i++){
		//cout<<pos[i]<<" ";
		to[pos[i]][0]=i;
	}
	for(int j=1;j<=62;j++){
		for(int i=1;i<=n;i++){
			to[i][j]=to[to[i][j-1]][j-1];
		}
	}	
	ll o=k;
	for(int i=1;i<=n;i++){
		k=o;
		//cout<<" ----------- "<<i<<endl;
		int now=i;
		for(int j=62;j>=0;j--){
			if(k>=(1LL<<j)) {
				k-=(1LL<<j);
				now=to[now][j];
				//cout<<j<<" "<<now<<endl;
			}
		}
		//cout<<i<<" : "<<now<<endl;
		ans[now]=cha[i];
	}
	
	double sum=0.0;
	for(int i=1;i<=n;i++){
		sum+=1.0*ans[i];
		printf("%lf\n",sum);
	}
	return 0;
}

Measured memory_bytes: 32768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 5e5 + 5;

int n, Q, ans[N], c[N], nex[N], cur[N], t[N];
struct Que {
	int l, r, id;
} q[N];

void update(int x, int k) {
	if(!x) return; 
	while(x <= n) {
		t[x] += k;
		x += x&-x;
	}
}

int Query(int x) {
	int res = 0;
	while(x) {
		res += t[x];
		x -= x&-x;
	}
	return res;
}

bool cmp(Que a, Que b) {
	return a.r < b.r;
}

int main() {
	cin>>n>>Q;
	rep(i, 1, n) {
		scanf("%d", &c[i]);
		nex[i] = cur[c[i]];
		cur[c[i]] = i;
	}
	rep(i, 1, Q) {
		scanf("%d%d", &q[i].l, &q[i].r);
		q[i].id = i;
	}
	sort(q + 1, q + Q + 1, cmp);
	int now = 0;
	rep(i, 1, Q) {
		while(now < q[i].r) {
			now++;
			update(nex[now], -1);
			update(now, 1);
		}
		ans[q[i].id] = Query(q[i].r) - Query(q[i].l - 1);
	} 
	rep(i, 1, Q)
	    cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 19384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll R, G; cin >> R >> G;
	cout << 2 * G - R << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

    static int maxCount;

    static void exec( int x, int y, final int dx, final int dy,
		      final int n, final String[] map ) {
	int count = 0;
	while ( 0 <= x && x < n && 0 <= y && y < n ) {
	    if ( map[y].charAt( x ) == '0' ) {
		if ( maxCount < count ) {
		    maxCount = count;
		}
		count = 0;
	    } else {
		count = count + 1;
	    }
	    x += dx;
	    y += dy;
	}
	if ( maxCount < count ) {
	    maxCount = count;
	}
    }
    
    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	
	while ( true ) {
	    final int n = Integer.parseInt( stdin.nextLine() );
	    if ( n == 0 ) {
		break;
	    }
	    String[] map = new String[n];
	    for ( int i = 0; i < n; i++ ) {
		map[i] = stdin.nextLine();
	    }

	    maxCount = 0;

	    for ( int c = 0; c < n; c++ ) {
		// たて
		exec( c, 0, 0, 1, n, map );
		// よこ
		exec( 0, c, 1, 0, n, map ); 
		// ななめ
		exec( 0, c, 1, 1, n, map);
		exec( 0, c, 1, -1, n, map);
		exec( c, 0, 1, 1, n, map);
		exec( c, n - 1, 1, -1, n, map);
	    }
	    System.out.println(maxCount);
	}
	
    }
    
}

Measured memory_bytes: 30056
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string s;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
# モジュールのインポート
from fractions import gcd

# 標準入力の取得
A, B, C, D = list(map(int, input().split()))


def lcm(x: int, y: int) -> int:
    return (x * y) // gcd(x, y)


# 求解処理
div_C = (B // C) - ((A - 1) // C)
div_D = (B // D) - ((A - 1) // D)
lcm_CD = lcm(C, D)
div_lcm_CD = (B // lcm_CD) - ((A - 1) // lcm_CD)
result = (B - A + 1) - div_C - div_D + div_lcm_CD

# 結果出力
print(result)


Measured memory_bytes: 5076
using System;
using System.ComponentModel.DataAnnotations;
using System.IO.Pipes;
using System.Linq;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int L = cin.NextInt();
            int R = cin.NextInt();
            int d = cin.NextInt();
            int ans = 0;

            for(int i = L; i <= R; i++)
            {
                if (i % d == 0)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



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

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

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

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BinaryHeap;

fn main() {
    let nm: Vec<usize> = read_vec();
    let av: Vec<u64> = read_vec();
    let mut bh: BinaryHeap<u64> = BinaryHeap::new();
    for a in av {
        bh.push(a);
    }
    for _ in 0..nm[1] {
        let tmp = bh.pop().unwrap();
        bh.push(tmp / 2);
    }
    println!("{:?}", bh.into_iter().fold(0, |sum, a| sum + a));
}


Measured memory_bytes: 9464
#include <iostream>
using namespace std;
typedef long long ll;
ll N;



int main(){
	cin >> N;
	string S = "";
	ll num = 2,pm = 1;
	if(N==0){
		cout << 0 << endl;
		return 0;
	}
	while(N!=0){
		if(N%num==0){
			S = '0' + S;
		}else{
			S = '1' + S;
			if(pm==1){
				N -= num/2;
			}else{
				N += num/2;
			}
		}
		num *= 2;
		pm *= -1;
//		cout << N << endl;
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  
  int n, m, i, f = 0;
  int a[100];
  double t, g = 0;
  
  scanf("%d %d", &n, &m);
  
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  
  for(i = 0; i < n; i++){
    g += a[i];
  }
  
  t = (g/(4*m));
  
  for(i = 0; i < n; i++){
    if(a[i] >= t){
      f++;
    }
  }
  
  if(f >= m){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
 
}

Measured memory_bytes: 1732
//arc074 q1 practice 2017/06/17
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <tuple>
#define pb push_back
#define mkt make_tuple
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
const int INF =  2147483647;
const ll INFLL = 9223372036854775807;

int subsubans(int h, int hi, int w) {
  int w1, s1, s2, s3;
  w1 = w / 2;
  s1 = hi * w;
  s2 = (h - hi) * w1;
  s3 = (h - hi) * (w - w1);
  return max(s1, max(s2, s3)) - min(s1, min(s2, s3));
}

int subans(int h, int w) {
  int ans, h1, h2;
  h1 = h / 3;
  h2 = h1+1;
  return min(subsubans(h, h1, w), subsubans(h, h2, w));
}

int answer() {
  int h, w, ans = INF;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0) {
    return 0;
  } else {
    ans = min(w, h);
  }
  return min(ans, min(subans(h, w), subans(w, h)));
}

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

  int ans = answer();

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256