akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	vector<int> F(N);
	for(int i=0; i<N; i++){
		for(int j=0; j<10; j++){
			int f;
			cin >> f;
			F[i] += f<<j;
		}
	}

	vector<vector<int>> P(N, vector<int>(11));
	for(int i=0; i<N; i++){
		for(int j=0; j<11; j++){
			cin >> P[i][j];
		}
	}

	ll ans = -1e12;
	for(int s=1; s<(1<<10); s++){
		ll sum = 0;
		for(int i=0; i<N; i++){
			int a = s & F[i];
			ll cnt = 0;
			for(int k=0; k<10; k++){
				if((a>>k)&1) cnt++;
			}
			debug(s, i, a, cnt, P[i][cnt]);
			sum += P[i][cnt];
		}
		ans = max(ans, sum);
		debug(ans);
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    string S;
    cin >> S;
    if(S=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3552
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			int N = Integer.parseInt(br.readLine());
			int[] a = strToIntArray(br.readLine());
			Arrays.sort(a);
			int sum = 0;
			for (int i = 0; i < a.length; i = i + 2) {
				sum += a[i];
			}

			System.out.println(sum);
		} catch (Exception e) {
			System.err.println("Error:" + e.getMessage());
		}
	}

	// Stringで読みこんでスペースで分割されている数字を配列に入れるやつ
	// 利用法 int[] A = strTointArray(br.readLine());
	static int[] strToIntArray(String S) {
		String[] strArray = S.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}


Measured memory_bytes: 8148
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
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;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, m;
	cin >> n >> m;
	VecP r(m);
	rep(i, m) cin >> r[i].fs >> r[i].sc;

	sort(all(r));

	ll ans = 0, end = 0, now = 0;
	while(now < m){
		end = r[now].sc;
		while(r[now+1].fs < end && now < m){
			now++;
			chmin(end, r[now].sc);
		}
		ans++;
		now++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,i,j,a,b;
    cin>>n;
    long long arr[n];
    for(i=0;i<n;i++)cin>>arr[i];
    a=0;
    b=1000;
    for(i=0;i<n;i++)
    {
        if(a==0)
        {
            if(i<n-1&&arr[i]<arr[i+1])
            {
                a=b/arr[i];
                b=b%arr[i];
            }
        }
        else
        {
            if(i==n-1||arr[i]>arr[i+1])
            {
                b=b+(a)*arr[i];
                a=0;
            }
        }
    }
    cout<<b;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main() {
    int k,s;
    cin>>k>>s;
    int n=0;
    for(int i=0;i<=k;++i){
        for(int j=0;j<=k;++j){
            if(i+j<=s&&s-k<=i+j){
                ++n;
            }
        }
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

ll N, M, K;
// the answer is
// (NM-2 C K-2) (N^2 (M+1 C 3) + M^2 (N+1 C 3))

void solve() {
	cin >> N >> M >> K;
	ll c = 1, d = 1;
	for(ll i = 0; i < K - 2; i++) {
		MUL(d, M * N - 2 - i);
		MUL(c, i + 1);
	}
	ll res = d * invf(c) % mod;
	ll tmp = 0;
	ADD(tmp, N * N % mod * (M + 1) % mod * M % mod * (M - 1) % mod * invf(6) % mod);
	ADD(tmp, M * M % mod * (N + 1) % mod * N % mod * (N - 1) % mod * invf(6) % mod);
	cout << res * tmp % mod << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
Public Class Compiler
    Shared Sub Main()
        Dim input As String() = Console.ReadLine().Split(" ")
        Dim n As Integer = Integer.Parse(input(0))
        Dim a As Integer = Integer.Parse(input(1))
        Dim b As Integer = Integer.Parse(input(2))
        Dim output As Integer = n * a
        If b < n * a Then output = b
        Console.WriteLine(output)
    End Sub
End Class

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int a, b, c, i;
    bool flag = false;
    scanf("%d%d%d", &a, &b, &c);
    for (i=1; i<a*b; i++)
    {
        if (a*i % b == c) {
            flag = true;
            break;
        }
    }
    if (flag) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int Q; cin >> Q;
    while(Q--){
        int R; cin >> R;
        int ans = 0;
        while(R >= 10){
            int next = 0;
            for(int x=10; x<=R; x*=10){
                next = max(next, (R/x) * (R%x));
            }
            R = next;
            ans++;
        }
        cout << ans << endl;
    }
    
    return 0;
}

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

char _ans[20];

void outputans(int n, int i, int index)
{
    if( i == n )
    {
        _ans[i] = '\0';
        cout << _ans << endl;
        return;
    }

    for( int j = 0; j <= index; j++)
    {
        _ans[i] = 'a' + j;       
        outputans(n, i + 1, max(index, j + 1) );
    }
}

int main()
{
    int n;
    cin >> n;
    outputans(n, 0, 0);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep (i, 0, n) {
        if (s[i] == '?') cout << 'D';
        else
            cout << s[i];
    }
    cout << "\n";
}

Measured memory_bytes: 3752
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int main(){
string a,b,c;
cin>>a>>b>>c;
cout<<a[0]<<b[0]<<c[0];
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <stack>
using namespace std;
map<string,long long>m;
typedef long long ll;


string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    int k,x;
    cin >>k >> x;
    for(int i=x-k+1;i<x+k;i++){
        cout << i<<" \n"[i==x+k-1];
    }
    return 0;
}


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

int main(){
    int a, b ;
    cin >> a >> b ;
    int sgn = 1 ;
    for(; a <= b ; ++a){
        if(a < 0)sgn = -sgn ;
        else if(a == 0){
            sgn = 0 ; 
            break;
        }
    }
    if(sgn == 1)cout << "Positive" << endl ;
    else if(sgn == -1)cout << "Negative" << endl ;
    else cout << "Zero" << endl ;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;

int main()
{
    int st,en,n;
    int a[maxn],b[maxn];
    while(scanf("%d%d%d",&st,&en,&n)!=EOF)
    {
        if(n>=en-st+1)
        {
            for(int i=st; i<=en; ++i)
            {
                printf("%d\n",i);
            }
        }
        else
        {
            for(int i=1; i<=n; ++i)
            {
                a[i] = st++;
                b[i] = en--;
            }
            sort(b+1,b+1+n);
            for(int i=1; i<=n; ++i)
            {
                printf("%d\n",a[i]);
            }
            for(int i=1; i<=n; ++i)
            {
                if(b[i]>a[n])
                    printf("%d\n",b[i]);
            }
        }
    }
    return 0;
}


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

int main() {
  int A;
  int B;
  int H;
  int M;
  cin>>A>>B>>H>>M;
  double kaku=3.141592653589793238462643*(11*M-60*H)/360;
  double kosain=cos(kaku);
  double nagasanonizyou=A*A+B*B-2*A*B*kosain;
  double nagasa=sqrt(nagasanonizyou);
  cout<<fixed<<setprecision(11)<<nagasa<<endl;
  
}



Measured memory_bytes: 4136
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w=mp()
g=["."*(w+2)]
for i in range(h):
    g.append("."+input()+".")
g.append("."*(w+2))
v=[[1,0],[-1,0],[0,1],[0,-1]]
for i in range(1,h+1):
    for j in range(1,w+1):
        if g[i][j]=="#":
            c=True
            for x,y in v:
                if g[i+x][j+y]=="#":
                    c=False
            if c:
                print("No")
                exit()
print("Yes")

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

int main() {
  int a1, a2, a3;
  cin >> a1;
  cin >> a2;
  cin >> a3;
  vector<int> A{a1, a2, a3};
  int min_cst = 9999;
  int tmp;
  for (int i=0; i<3; i++){
    tmp = 0;
    for (int j=0; j<3; j++){
      if (i == j){
        continue;
      }
      tmp = 0;
      tmp += abs(A[i] - A[j]);
      for (int k=0; k<3; k++){
        if (j == k){
          continue;
        }
        if (i == k){
          continue;
        }
        tmp += abs(A[j] - A[k]);
        if (tmp < min_cst){
          min_cst = tmp;
        }
      }
    }
  }
  cout << min_cst << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), M = scanner.nextInt(), R = scanner.nextInt();
        scanner.nextLine();
        Set<Integer> rs = Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).map(x -> x - 1).collect(Collectors.toSet());
        int[][] dist = new int[N][N];
        for (int[] d: dist) {
            Arrays.fill(d, Integer.MAX_VALUE / 2);
        }
        for (int i = 0; i < M; i++) {
            int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            dist[e[0] - 1][e[1] - 1] =  e[2];
            dist[e[1] - 1][e[0] - 1] =  e[2];
        }

        for (int via = 0; via < N; via++) {
            for (int from = 0; from < N; from++) {
                for (int to = 0; to < N; to++) {
                    if (dist[from][to] > dist[from][via] + dist[via][to]) {
                        dist[from][to] = dist[from][via] + dist[via][to];
                    }
                }
            }
        }

        System.out.println(dfs(rs, -1, dist));
    }

    private static int dfs(Set<Integer> remaining, int curr, int[][] dist) {
        if (remaining.isEmpty()) {
            return 0;
        }
        int ans = Integer.MAX_VALUE / 2;
        for (int r: new ArrayList<>(remaining)) {
            remaining.remove(r);
            if (curr == -1) {
                ans = Math.min(ans, dfs(remaining, r, dist));
            } else {
                ans = Math.min(ans, dfs(remaining, r, dist) + dist[curr][r]);
            }
            remaining.add(r);
        }
        return ans;
    }

}

Measured memory_bytes: 50876
#include<bits/stdc++.h>
#define INF (1<<30)
using namespace std;
int n,m;
int p[10000];
int c[500];
int e[500];
int dp[20000];
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p,p+n,greater<int>());
  for(int i=0;i<m;i++){
    cin>>c[i]>>e[i];
  }
  
  for(int i=0;i<20000;i++) dp[i]=INF;
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int j=n;j>=0;j--){
      dp[j]=min(dp[j],dp[max(j-c[i],0)]+e[i]);
    }
  }
  int ans=0;
  int sum=0;
  for(int i=0;i<=n;i++){
    ans=max(ans,sum-dp[i]);
    if(i<n) sum+=p[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

ll a[100000];
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		ll x; cin >> x;
		a[i] = x;
	}
	// all 0
	bool ok = true;
	rep(i, 0, n) ok &= (a[i] == 0);

	if (ok) {
		cout << "Yes" << endl;
		return 0;
	}

	if (n % 3) {
		cout << "No" << endl;
		return 0;
	}

	map<ll, ll> m;
	rep(i, 0, n) {
		m[a[i]]++;
	}

	if (m.size() > 3) {
		cout << "No" << endl;
		return 0;
	}
	else if (m.size() == 3) {
		ok = true;
		ll v = 0;
		for (map<ll, ll>::iterator it = m.begin(); it != m.end(); it++) {
			ok &= (it->second == n / 3);
			v ^= it->first;
		}

		if (v == 0 && ok) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	else if (m.size() == 2) {
		if (m[0] == n / 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 5632
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;


int saiki(long long int N)
{
	if (N <= 3)return 1;
	return saiki(max(N/3,(N-(int)N/3+1)/2))+1;
}

int main()
{
	long long int N;
	cin >> N;
	cout<<saiki(N)<<endl;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args)
	{
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(br.readLine());
			int[] A = new int[n];
			for(int i = 0; i<n ; i++)
			{
				A[i] = Integer.parseInt(br.readLine());
			}
			shellSort(A,n);
			
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shellSort(int[] arr , int l)
	{
		
		int m = 1 ,cnt =0;
		int G[] = new int[14];
		G[0] = 1;
		while((G[m] = G[m-1] * 3 +1) <= l){
			m++;
		}
		sb.append(m).append('\n');
		m--;
		for(; m >= 0 ; m--){
			sb.append(G[m]).append(' ');
			cnt += insertionSort(arr,l,G[m]);
		}
		sb.deleteCharAt(sb.length()-1).append('\n').append(cnt).append('\n');
		
		for(m = 0 ; m < l ; m++){
			sb.append(arr[m]).append('\n');
		}
			System.out.print(sb.toString());
	}
	public static int insertionSort(int[] a,int n , int g)
	{
		int cnt = 0;
		int v;
		for(int i = g ; i < n ; i++)
		{
			v = a[i];
			int j = i-g;
			while(j >= 0 && a[j] > v)
			{
				a[j+g] = a[j];
				a[j] = v;
				j -= g;
				cnt++;
			}
		}
		return cnt;
	}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll pow(ll x, ll y, ll mod) {
    if (y == 0) {
        return 1;
    }
    if (y % 2 == 0) {
        return pow(x * x % mod, y / 2, mod) % mod;
    } else {
        return x * pow(x, y - 1, mod) % mod;
    }
}

ll f(ll n, ll k) {
    ll res = 1;
    rep2(i, 1, k + 1) {
        res *= (n - i + 1);
        res %= MOD;
        res *= pow(i, MOD - 2, MOD);
        res %= MOD;
    }
    return res;
}


void Main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = pow(2, N, MOD);
    ans %= MOD;
    ans -= 1;
    if (ans < 0) ans += MOD;
    ans -= f(N, A);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    ans -= f(N, B);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans % MOD << '\n';
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a % b > 0)
    {
        cout << "1" << endl;
    }
    else
    {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])
	const As = input[1].split(" ").map(x => parseInt(x))
	const Bs = input[2].split(" ").map(x => parseInt(x))
	const now = As

	var count = 0
	for(i=0; i < N; i++){
		if(now[i] <= Bs[i]){
			var b = now[i]
			count += b
			if(now[i+1] <= Bs[i] - b){
				count += now[i+1]
				now[i+1] = 0
			}else{
				count += Bs[i] - b
				now[i+1] = now[i+1] - (Bs[i] - b)
			}
		}else{
			count += Bs[i]
		}
	}
	console.log(count)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2],R[MAX / 2 +2];

llong merge (int A[], int n, int left,int mid, int right) {
  int i,j,k;
  llong cnt = 0;
  int n1=mid - left;
  int n2=right - mid;
  for (i=0;i<n1;i++) {
    L[i] = A[left + i];
  }
  for (i=0;i<n2;i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for (k=left;k<right;k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[],int n,int left,int right) {
  int mid;
  llong v1,v2,v3;
  if (left +1 < right) {
    mid = (left + right)/2;
    v1 = mergeSort(A,n,left,mid);
    v2 = mergeSort(A,n,mid,right);
    v3 = merge(A,n,left,mid,right);
    return v1+v2+v3;
  }else return 0;
}

int main () {
  int A[MAX],n,i;
  cin >> n;
  for (i=0;i<n;i++) {
    cin >> A[i];
  }

  llong ans = mergeSort(A,n,0,n);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4660
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

long long f[100005],w[101];
int v[101],tot;

int main()
{
	int N;
	long long W;
	scanf("%d%lld",&N,&W);
	for(int i=1;i<=N;++i)
	scanf("%lld%d",&w[i],&v[i]),tot+=v[i];
	for(int i=1;i<=tot;++i)
	f[i]=1e18;
	//cout<<v[1]<<endl;
	for(int i=1;i<=N;++i)
	for(int j=tot;j>=v[i];--j)
	if(f[j]>f[j-v[i]]+w[i])
	f[j]=f[j-v[i]]+w[i];
	for(int i=tot;i>=0;--i)
	if(f[i]<=W)
	{
		//cout<<f[i]<<endl; 	
		printf("%d",i);
		break;	
	} 
	return 0;
}

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

int main() {
    int n;
    int k;
    cin>>n>>k;
    int a[n];
    int dp[n] = {0};
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
    for(int i = n - 2; i >= 0 ; i--){
        int mini = INT_MAX;
        for(int j = i + 1; j <= i +k && j < n;j++){
            mini = min(mini, max(a[j] - a[i], a[i] - a[j]) + dp[j]);
        }
        dp[i] = mini;
    }
    cout<<dp[0];
	// your code goes here
	return 0;
}


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

int main(){
  long long int N, C;
  cin >> N >> C;
  vector< pair<long long int, long long int> > V;
  long long int x, v;
  for(int i = 0; i < N; ++i){
    cin >> x >> v;
    V.emplace_back(x, v);
  }
  long long int ans = 0, t = 0;
  //右回り
  vector<long long int> R(N), L(N);
  for(int i = 0; i < N; ++i){
    t += V[i].second - V[i].first;
    if(i > 0) t += V[i-1].first;
    ans = max(ans, t);
    R[i] = ans;
  }
  t = 0, ans = 0;
  for(int i = N-1; i >= 0; --i){
    t += V[i].second + V[i].first - C;
    if(i < N-1) t += C - V[i+1].first;
    ans = max(ans, t);
    L[i] = ans;
  }
  t = 0;
  for(int i = 0; i < N-1; ++i){
    t += V[i].second;
    ans = max(ans, t - 2*V[i].first + L[i+1]);
  }
  t = 0;
  for(int i = N-1; i > 0; --i){
    t += V[i].second;
    ans = max(ans, t + 2*(V[i].first - C) + R[i-1]);
  }
  ans = max(ans, R[N-1]);
  ans = max(ans, L[0]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
	visited[v] = true;
	rep(v2, n) {
		if (!graph[v][v2])continue;
		if (visited[v2]) continue;
		dfs(v2);
	}
}

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

	cin >> n >> m;

	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	int ans = 0;

	rep(i, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		rep(j, n) visited[j] = false;

		dfs(0);

		bool bridge = false;
		rep(j, n)
			if (visited[j] == false) bridge = true;
		if (bridge) ans++;

		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))

dis = []
for i in range(n - k + 1):
    x1 = x[i]
    x2 = x[i + k - 1]
    dis_i = min(abs(x1), abs(x2)) + abs(x1 - x2)
    dis.append(dis_i)

print(min(dis))

Measured memory_bytes: 14384
#include <bits/stdc++.h>
using namespace std;
class a{
public:
    int x;
    int y;
};
bool com(class a x,class a y){
    if(x.x!=y.x)
        return x.x<y.x;
    else return x.y<y.y;
}
int main() {
    int n;cin>>n;
    //int p[100000][2];
    auto *p=new class a [n];
    for (int i = 0; i < n; ++i) {
        cin>>p[i].x>>p[i].y;
    }
    sort(p+0,p+n,com);
    for (int i = 0; i < n; ++i) {
        cout<<p[i].x<<" "<<p[i].y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n+1),b(n+1,0);
    rep(i,n){
        cin>>a[i+1];
    }
    int ans=0;
    for(int i=n;i>=1;i--){
        int cnt=0;
        for(int j=i+i;j<=n;j+=i){
            cnt+=b[j];
        }
        if(cnt%2!=a[i]%2){
            ans++;
            b[i]=1;
        }
    }
    cout<<ans<<endl;
    FOR(i,1,n+1) if(b[i]) cout<<i<<endl;
}

Measured memory_bytes: 4776
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if n < m:
    x_distance = [x[i + 1] - x[i] for i in range(m - 1)]
    x_distance.sort()
    ans = 0
    for i in range (m - n):
        ans += x_distance[i]
    print(ans)
else:
    print(0)


Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,w,h; cin >> n >> w >> h;
    vector<int> a(w+1),b(h+1);
    while(n--){
        int x,y,z; cin >> x >> y >> z;
        int xx=max(0,x-z);
        int xxx=min(x+z,w);
        a[xx]++; a[xxx]--;
        int yy=max(0,y-z);
        int yyy=min(y+z,h);
        b[yy]++; b[yyy]--;
    }
    for(int i=0;i<=w;i++){
        a[i+1]+=a[i];
    }
    for(int i=0;i<=h;i++){
        b[i+1]+=b[i];
    }
    bool ok=1;
    bool ok2=1;
    for(int i=0;i<w;i++){
        if(a[i]<1)ok=0;
    }
    for(int i=0;i<h;i++){
        if(b[i]<1)ok2=0;
    }
    if(ok||ok2)printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3616
const log = console.log;

function Main(input: string): void {
  const [a, b] = input
    .trim()
    .split(/\s/g)
    .map(s => parseInt(s));

  if (a >= 13) {
    log(b);
  } else if (a >= 6) {
    log(b / 2);
  } else {
    log(0);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long 
//#define int long long
#define ld long double
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define iii pair<int,ii>
#define il pair<int,ll>
#define pll pair<ll,ll>
#define _path pair<ll,pair<ll,int> > // length, numlength, node,we also take numlength to be negetive so that paths with the same length is sorted by descending order of number of such path. this is essential otherwise it will lead to undercounting of number of same length paths
#define vv vector
//#define endl '\n'
using namespace std;

const int MAXN = 200*1000 + 5;
const ll INF = 1e17;
const ll MOD = 1e9 +7;

bool isOnEdge(int r,int c,ii p){
	if(p.ff == r or p.ff == 0)return 1;
	if(p.ss == c or p.ss == 0)return 1;
	
	return 0;
}
int R,C;
int zone(ii x){
	if(x.ss == 0)return 1;
	if(x.ss == C)return 3;
	if(x.ff == R)return 2;
	else return 4;
}

int start[MAXN];

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

	int n;
	cin >> R >> C >> n;
	//vv<pair<ii,ii> > all;
	vv<pair<ii,int> > points;
	FOR(i,n){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if(isOnEdge(R,C,{a,b}) and isOnEdge(R,C,{c,d})){
			//all.push({{a,b},{c,d}});
			points.pb({{a,b},i});
			points.pb({{c,d},i});
		}
	}
	// valid points.
	// lets assign all the numbers a index;
	//cout << zone({1,1}) << " " << zone({0,1}) << endl;
	sort(points.begin(), points.end(), [&](pair<ii,int> e1, pair<ii,int> e2){
		if(zone(e1.ff) != zone(e2.ff))return zone(e1.ff) < zone(e2.ff);
		switch(zone(e1.ff)){
			case 1:{
				return e1.ff.ff < e2.ff.ff;
			}
			case 2:{
				return e1.ff.ss < e2.ff.ss;
			}
			case 3:{
				return e1.ff.ff > e2.ff.ff;
			}
			case 4:{
				return e1.ff.ss > e2.ff.ss;
			}
		}
	});
	FOR(i,MAXN)start[i] = -1;
	stack<int> st;
	for(auto e: points){
		if(st.empty())st.push(e.ss);
		else if(st.top() != e.ss)st.push(e.ss);
		else st.pop();
	}
	if(st.empty()){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 6844
#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;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,sum=0;
  string s,s2;
  cin>>s;
  s2=s;
  reverse(s.begin(), s.end());
  if(s2==s){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
a = [int(i) for i in input().split()]

def fight(a):
    a.sort()
    survive = [a[0]]
    for i in range(1,len(a)):
        if a[i]%a[0]!=0:
            survive.append(a[i]%a[0])
    return survive

while len(a)>1:
    a = fight(a)

print(a[0])


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
const int MOD = 1e9+7;

ll power(ll a, ll b){
    ll r=1;
    while(b>0){
        if(b&1)
            r=r*a %MOD;
        a = a*a %MOD;
        b/=2;
    }
    return r;
}

int main(){
    ull a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if(k&1)
        ans = b-a;
    else
        ans = a-b;

    cout << ans;
}


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

int n, k, a, gcd, Max;

int main() {
    //kがgcdで割り切れるMax以下のとき正解
    cin >> n >> k;
    while (n--) {
        cin >> a;
        gcd = __gcd(gcd, a);
        Max = max(Max, a);
    }
    string ans = "IMPOSSIBLE";
    if (k % gcd == 0 && k <= Max) ans = "POSSIBLE";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (c1).begin(),(c1).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

string s;

int main() {
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))

const ll mod = 1e9 + 7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll a , ll b){ a = a%mod; if(b == 0) return 1LL;if(b&1)  return (a*1LL*expo(a , b - 1))%mod;ll t = expo(a , b/2);return (t*1LL*t)%mod;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

const int M = 2e6 + 5;
int lo[M];
void sieve(){
    lo[1] = 0;
    for(int i = 2 ; i < M ; i++){
        if(lo[i]) continue;
        lo[i] = i;
        for(int j = i + i ; j < M ; j += i){
            lo[j] = i;
        }
    }
}
int arr[M] , pre[M];

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    sieve();

    for(int i = 1 ; i < M ; i++){
        if(i&1 && lo[i] == i){
            int xx = (i+1)/2;
            if(lo[xx] == xx){
                arr[i] = 1;
            }
        }
        pre[i] = pre[i - 1] + arr[i];
    }



    int Q;
    si(Q);

    while(Q--){
        int L, R;
        si(L);  si(R);
        int ans = pre[R] - pre[L - 1];
        printf("%d\n" , ans);
    }















}














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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO;
	int k,ans=0;
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int l=1;l<=k;l++)
			{
				int x;
				x=__gcd(i,j);
				x=__gcd(x,l);
				ans+=x;
			}
		}
	}
	cout<<ans<<nl;
	return 0;
}


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

int bubbleSort(int A[], int N){
	int swapNumber = 0;
	int flag = 1;
	int i, j;
	for(i = 0; flag; i++){
		flag = 0;
		for(j = N-1; j >= i+1; j--){
			if(A[j - 1] > A[j]){
				flag = 1;
				swap(A[j], A[j - 1]);
				swapNumber++;
			}
		}
	}
	return swapNumber;
}
int main(int argc, char const *argv[])
{
	int A[100];
	int N, swapNumber;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	swapNumber = bubbleSort(A, N);
	for(int i = 0; i < N; i++){
		if(i){
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
	cout << swapNumber <<endl;
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 605
struct Edge{

	int from,to;
	char buf[6];
	int len;
};

int N1,N2,M1,M2;
ll dp[SIZE][SIZE][6][6];
Edge edge1[SIZE],edge2[SIZE];
vector<int> G1[SIZE],G2[SIZE];

ll recursive(int e1,int loc1,int e2,int loc2){

	if(dp[e1][e2][loc1][loc2] != -1){

		return dp[e1][e2][loc1][loc2];
	}

	if(edge1[e1].buf[loc1] != edge2[e2].buf[loc2]){

		return dp[e1][e2][loc1][loc2] = 0;
	}

	ll ret = 0;

	if(loc1+1 < edge1[e1].len && loc2+1 < edge2[e2].len){ //両方非終端

		ret = recursive(e1,loc1+1,e2,loc2+1);

	}else if(loc1+1 == edge1[e1].len && loc2+1 < edge2[e2].len){ //DAG1が終端

		if(edge1[e1].to == N1-1){

			ret = 0;

		}else{ //DAG1が新しいノードへ

			for(int i = 0; i < G1[edge1[e1].to].size(); i++){

				ret += recursive(G1[edge1[e1].to][i],0,e2,loc2+1);
				ret %= MOD;
			}
		}

	}else if(loc1+1 < edge1[e1].len && loc2+1 == edge2[e2].len){ //DAG2が終端

		if(edge2[e2].to == N2-1){

			ret = 0;

		}else{ //DAG2が新しいノードへ

			for(int i = 0; i < G2[edge2[e2].to].size(); i++){

				ret += recursive(e1,loc1+1,G2[edge2[e2].to][i],0);
				ret %= MOD;
			}
		}

	}else{ //両方終端

		if((edge1[e1].to == N1-1 && edge2[e2].to != N2-1) ||
				(edge1[e1].to != N1-1 && edge2[e2].to == N2-1)){ //片方だけ文章完成

			ret = 0;

		}else if(edge1[e1].to == N1-1 && edge2[e2].to == N2-1){ //両方文章完成

			ret = 1;

		}else{ //両方新しいノードへ

			for(int i = 0; i < G1[edge1[e1].to].size(); i++){
				for(int k = 0; k < G2[edge2[e2].to].size(); k++){

					ret += recursive(G1[edge1[e1].to][i],0,G2[edge2[e2].to][k],0);
					ret %= MOD;
				}
			}
		}
	}

	return dp[e1][e2][loc1][loc2] = ret;
}


void func(){

	for(int i = 0; i < SIZE; i++){
		G1[i].clear();
		G2[i].clear();
	}

	scanf("%d %d",&N1,&M1);

	for(int i = 0; i < M1; i++){

		scanf("%d %d %s",&edge1[i].from,&edge1[i].to,edge1[i].buf);
		for(edge1[i].len = 0; edge1[i].buf[edge1[i].len] != '\0'; edge1[i].len++);

		G1[edge1[i].from].push_back(i);
	}

	scanf("%d %d",&N2,&M2);

	for(int i = 0; i < M2; i++){

		scanf("%d %d %s",&edge2[i].from,&edge2[i].to,edge2[i].buf);
		for(edge2[i].len = 0; edge2[i].buf[edge2[i].len] != '\0'; edge2[i].len++);

		G2[edge2[i].from].push_back(i);
	}

	for(int i = 0; i < M1; i++){
		for(int k = 0; k < M2; k++){
			for(int a = 0; a < 6; a++){
				for(int b = 0; b < 6; b++){
					dp[i][k][a][b] = -1;
				}
			}
		}
	}

	ll ans = 0;
	int root = 0;

	for(int i = 0; i < G1[root].size(); i++){
		for(int k = 0; k < G2[root].size(); k++){

			ans += recursive(G1[root][i],0,G2[root][k],0);
			ans %= MOD;
		}
	}

	printf("%lld\n",ans);
}

int main(){

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

	for(int loop = 0; loop < num_case; loop++){

		func();
	}

	return 0;
}



Measured memory_bytes: 105420
l=input()
a=int(l[0])
b=int(l[1])
c=int(l[2])
d=int(l[3])
for i in range(2**3):
  s=0
  lis=[]
  for j in range(3):
    if (i>>(2-j)&1)!=1:
      if j==0:
        s+=a-b
        x='-'
      elif j==1:
        s-=c
        y='-'
      else:
        s-=d
        z='-'
    else:
      if j==0:
        s+=a+b
        x='+'
      elif j==1:
        s+=c
        y='+'
      else:
        s+=d
        z='+'
  if s==7:
    print(str(a)+x+str(b)+y+str(c)+z+str(d)+'=7')
    exit()

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

int main()
{
  string s;
  cin >> s;
  for(int i=0;i<s.size()-1;i++)
    if(s[i]=='A' and s[i+1]=='C')
    {
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,m;
 cin>>n>>m;
 set<long long int>s;
 while(m--)
 {
     int k;
     cin>>k;
     int a[k];
     for(int i=0;i<k;i++)
     {
         cin>>a[i];
         s.insert(a[i]);
     }
 }
 cout<<n-s.size();
 
}

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

int main(){
    string a, b;
    cin >> a >> b;
    string ab = a + b;
    int i = stoi(ab);
    int j = sqrt(i);
    double k = sqrt(i);
    if (j == k) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

bool judge(string s,int start,int end){
    if(end-start==2)return false;
    int len=end-start-1;
    //int r=len/2-1;
    //if(start==0)r=(len-1)/2-1;
    bool res=true;
    rep(i,len/2+1){
        res&=s[start+i]==s[end-1-i];
    }
    return res;
}

signed main(void){
    string s;cin>>s;
    int len=s.length();
    bool ans;
    int mid=len/2;
    ans=judge(s,0,mid)&&judge(s,mid+1,len);
    ans&=judge(s,0,len);
    
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)
ll dp[101][space];
int main()
{
    int n,i,j,t;
    boost;
    int k;
    cin>>n>>k;
    int arr[n];
    rep(i,0,n)cin>>arr[i];

   // sort(arr,arr+n,greater<int>());

    ll pre[k+2];
    pre[0]=0;

    rep(i,0,k+1)
    {
        dp[0][i]=(arr[0]>=i);
        pre[i+1]=dp[0][i]+pre[i];
    }
    rep(i,1,n)
    {
        dp[i][0]=1;
        rep(j,1,k+1)
        {
            dp[i][j]=pre[j+1]-pre[max(0,j-arr[i])];
            dp[i][j]+=mod;
            dp[i][j]%=mod;
        }
        rep(j,0,k+1)pre[j+1]=(pre[j]+dp[i][j])%mod;
    }
    cout<<dp[n-1][k];

    return 0;
}



Measured memory_bytes: 79104