akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll dp[100];

int main() {
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	FOR(i, 4, 31) {
		dp[i] += dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	while (cin >> n&&n) {
		cout << dp[n] / 3650 + 1 << endl;
	}
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    string s; cin >> s;
    ll ans = 0, b = 0;
    rep(i, n) {
        if(s[i] == '#') b++;
        else if(b > 0) ans++, b--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3764
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <string.h>
#define true 1
#define false 0

int l;
int s;
int x, y, z;

int main() {
	int ans = 0;
	scanf("%d %d", &l, &s);
	for (int i = 0; i <= l; i++) {
		for (int j = i; j <= l; j++) {
			for (int k = j; k <= l; k++) {
				if (i + j + k == s) {
					if (i == k && k == j) {
						ans++;
					}
					else if (i != k && k != j && i != j) {
						ans += 6;
					}
					else {
						ans += 3;
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    int min = 100;
    int max = 0;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
        if (min > tmp) min = tmp;
        if (max < tmp) max = tmp;
    }
    long sum = LLONG_MAX;
    long tmp = 0;
    for (int i = min; i <= max; ++i) {
        for (int j = 0; j < n; ++j) {
            tmp += (v.at(j) - i) * (v.at(j) - i);
        }
        if (sum > tmp) sum = tmp;
        tmp = 0;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 888
/*
 *  * main.cpp
 *   *
 *    */

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

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main() {

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

    int res;
    for (int i = 2; i < 500000; i++) {
        if (i < X) continue;
        bool isPrime = true;
        for (int j = 2; j * j <= i; ++j) if (i % j == 0) isPrime = false;

        if (isPrime) {
            res = i;
            break;
        }
    }
    printf("%d\n", res);




    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef complex<double> P;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

//AOJ 2293

struct edge{
	int to, cost, cap, rev;
	edge(int _to, int _cost, int _cap, int _ret):to(_to),cost(_cost),cap(_cap),rev(_ret){};
};

int n,a[1111],b[1111];
int inf = 1111111111;
vector<vector<edge> > g;
set<int> si;
int nid[1111111];
int dist[3333],nv,pe[3333],pv[3333];
 
void addedge(int from, int to, int cost, int cap){
	g[from].PB(edge(to, cost, cap, g[to].size()));
	g[to].PB(edge(from,-cost, 0, g[from].size()-1));
}

inline void shortest_path(){
	int flag = true;
	REP(i,nv)dist[i]=inf;
	dist[0]=0;
	while(flag){
		flag = false;
		REP(i,nv){
			REP(j,g[i].size()){
				if(g[i][j].cap > 0 && dist[g[i][j].to]>dist[i]+g[i][j].cost){
					dist[g[i][j].to]=dist[i]+g[i][j].cost;
					pe[g[i][j].to]=j;
					pv[g[i][j].to]=i;
					flag = true;
				}
			}
		}
	}
}

int MinCostFlow(int t, int f){
	int ret = 0;
	while(f){
		shortest_path();
		if(dist[t]==inf)return inf;
		f--;
		ret+=dist[t];
		int c=t;
		while(c!=0){
			g[pv[c]][pe[c]].cap--;
			g[c][g[pv[c]][pe[c]].rev].cap++;
			c=pv[c];
		}
	}
	return ret;
}

int main(){
	cin>>n;
	REP(i,n){
		scanf("%d%d", &a[i], &b[i]);
		si.insert(a[i]);
		si.insert(b[i]);
	}
	nv=si.size()+n+3;
	int k=n+1;
	memset(nid, -1, sizeof(nid));
	g=vector<vector<edge> >(nv);
	REP(i,n){
		int va,vb;
		addedge(0,i+1,0,1);
		if(nid[a[i]]==-1)nid[a[i]]=k++;
		if(nid[b[i]]==-1)nid[b[i]]=k++;
		addedge(i+1,nid[a[i]],-b[i],1);
		addedge(i+1,nid[b[i]],-a[i],1);
		addedge(i+1,nv-2,0,1);
	}
	FOR(i,n+1,nv-2)addedge(i,nv-1,0,1);
	addedge(nv-2,nv-1,0,inf);
	cout << -MinCostFlow(nv-1,n) << endl;
}

Measured memory_bytes: 6012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;

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

int main(){	
	int t, n;
	while(cin >> t >> n, t|n){
		map<P, int> visit;

		rep(i, n){
			int x, y;
			cin >> x >> y;
			visit[MP(x, y)] = 1;
		}

		int sx, sy;
		cin >> sx >> sy;

		queue<pair<P, int> > q;
		q.push(MP(MP(sx, sy), 0));

		int ans = 0;

		while(!q.empty()){
			P p = q.front().first;
			int turn = q.front().second;
			q.pop();

			if(visit[p]) continue;
			visit[p] = 1;
			ans++;

			if(turn == t) continue;

			rep(i, 6){
				int x = p.first + dx[i];
				int y = p.second + dy[i];
				q.push(MP(MP(x, y), turn+1));
			}
		}

		cout << ans << endl;
	}

	
	return 0;
}

Measured memory_bytes: 1412
#include <stdio.h>

int main(void) {
	int n;
	int a[101][101]={0};
	int i,j,k,l;
	int max,now;
	scanf("%d",&n);
	for(i=1;i<=n;i++) {
		for(j=1;j<=n;j++)scanf("%d",&a[i][j]);
	}
	for(i=1;i<=n;i++) {
		for(j=1;j<=n;j++)a[i][j]+=a[i][j-1];
	}
	for(j=1;j<=n;j++) {
		for(i=1;i<=n;i++)a[i][j]+=a[i-1][j];
	}

	max=-100000000;
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			for(k=i+1;k<=n;k++) {
				for(l=j+1;l<=n;l++) {
					now=a[k][l]-a[k][j]-a[i][l]+a[i][j];
					if(now>max)max=now;
				}
			}
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 648
<?php
/**
 * ABC120
 * B - K-th Common Divisor
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d %d", $A, $B, $K);
$min = min($A, $B);
for ($i = $min; $i > 0; $i--) {
    if ($A % $i === 0 and $B % $i === 0) {
        $list[] = $i;
    }
}

echo $list[$K - 1], PHP_EOL;


Measured memory_bytes: 4604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int answer = a / (b * 2 + 1);
        if (a % (b*2+1) != 0) {
            answer++;
        }
        
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int h[] = new int[N];

		for(int n=0;n<N;n++){
			h[n] = sc.nextInt();
		}

		int dp[] = new int[N];
		dp[0] = 0;
		dp[1] = Math.abs(h[1]-h[0]);
		for(int n=2;n<N;n++){
			dp[n] = Math.min(dp[n-1]+Math.abs(h[n]-h[n-1]),dp[n-2]+Math.abs(h[n]-h[n-2]));
		}

		System.out.println(dp[N-1]);

	}
}

Measured memory_bytes: 51348
#include<stdio.h>
#include<math.h>

main(){
  double n;
  
  while(scanf("%lf",&n)!=EOF){

    double v=0,t,y,N;
    
    for(N=1;n>v;N++){
      y=5*N-5;
      t=sqrt(y/4.9);
      v=9.8*t;
    }

    printf("%.0f\n",N-1);
    
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

string N;

void _main() {
    cin >> N;
    REP (i, N.size()) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int n,a[50];

int solve(int i,int m){
	if(m==0) return 1;
  	if(i>=n) return 0;
  	int res = solve(i+1,m) || solve(i+1,m-a[i]);
  	return res;
  
}

int main() {
	cin>>n;
  	for(int i=0;i<n;i++) cin>>a[i];
  	
  	int q,m;
  	cin>>q;
  	for(int i=0;i<q;i++){
    	cin>>m;
      if(solve(0,m)){
      	cout<<"yes"<<endl;
      }else{
      	cout<<"no"<<endl;
      }
    }  
}



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

static const int MAX = 50;
static const int INF = 1e+9;
int a[MAX], b[MAX], c[MAX], d[MAX];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < m; i++){
        cin >> c[i] >> d[i];
    }
    for(int i = 0; i < n; i++){
        int dist = INF;
        int ans = 1;
        for(int j = 0; j < m; j++){
            //printf("%d %d\n", abs(a[i]-c[j]), abs(b[i]-d[j]));
            if(dist > abs(a[i]-c[j]) + abs(b[i]-d[j])){
                dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3480
program p2
    implicit none
    character(len=1005)::s, t
    integer::tmp, ans, i, j, ls, lt
    read(*,*) s, t
    ls = len_trim(s)
    lt = len_trim(t)
    ans = lt
    do i = 1, ls-lt+1
        tmp = 0
        do j = 1, lt
            if(s(i+j-1:i+j-1) .ne. t(j:j))  tmp = tmp + 1
        end do
        ans = min(tmp,ans)
    end do
    write(*,*) ans
    stop
end program

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

using namespace std;

int main(){

  int n,m;
  cin>>n>>m;

  char A[n][n];
  char B[n][n];
  bool prtN=true;

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){ 
      cin>>A[i][j];
    }
  }
  
  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){ 
      cin>>B[i][j];
    }
  }

  for(int ay=0; ay<n-m+1; ay++){
    for(int ax=0; ax<n-m+1; ax++){
      bool judge=false;
      for(int by=0; by<m; by++){
        if(by!=0 and judge==false){
          break;
        }
        for(int bx=0; bx<m; bx++){
          if(A[ay+by][ax+bx]==B[by][bx]){
            judge=true;
          }else{
            judge=false;
            break;
          }
        }
      }
      if(judge and prtN==true){
        cout<<"Yes"<<endl;
        prtN=false;
      }
    }
  }

  if(prtN) cout<<"No"<<endl;


}


Measured memory_bytes: 3624
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(ll& x: a) cin >> x;

	ll sum = 0, mx = a[0];
	for(int i = 1; i < n; i++) {
		mx = max(mx, a[i]);
		sum += (mx - a[i]);
	} 
	cout << sum << endl;

}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    ll n, k;
    cin >> n >> k;
    vl a(n);
    read(a, n);
    sort(a.begin(), a.end());
    ll sum = 0;
    Fori(i, 0, k) {
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define BIG 10e9
using namespace std;

int main() {
	int minv = BIG;
	int maxv = -BIG;
	int mi = 0;
	int n = 0;
	int r = 0;
	scanf("%d", &n);
	for (int i = 0; i<n; i++) {
		scanf("%d", &r);
		maxv = max(maxv, r-minv);
		minv = min(r, minv);
	}
	printf("%d\n",maxv);
	return 0;
}

Measured memory_bytes: 3220
n, m = map(int,input().split())
count = 0
l = []

for i in range(n):
  for i2 in range(i,n):
    if i != i2:
      l.append([i,i2])

for i in range(m):
  for i2 in range(i,m):
    if i != i2:
      l.append([i,i2])
print(len(l))

Measured memory_bytes: 3956
x,n=(int(i) for i in input().split())
if(n==0):
  print(x)
else:
  l=sorted([int(i) for i in input().split()])
  if(x not in l):
    print(x)
  else:
    k=l.index(x)
    c1,c2=0,0
    for i in range(k-1,-1,-1):
      if(x-l[i]>k-i):
        c1=l[i+1]-1
        break
    if(c1==0):
      c1=l[0]-1
    for i in range(k+1,n):
      if(l[i]-x>i-k):
        c2=l[i-1]+1
        break
    if(c2==0):
      c2=l[n-1]+1
    if(x-c1>c2-x):
      print(c2)
    else:
      print(c1)

Measured memory_bytes: 9272
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll A,B;
ll C(ll A,ll B){
	if(A==B) return 1LL;
	int fr = 0;
	ll ans = 0;
	for(int i=60;i>=0;i--){
		if(B >= (1LL<<i)){
			ll zip = B-(1LL<<i);
			for(int j=60;j>=0;j--){
				if(zip >= (1LL<<j)){
					fr = j+1; break;
				}
			}
			if(A >= (1LL<<i)){
			    return C(A-(1LL<<i),B-(1LL<<i));
			}
			ans += (1LL<<i)-A; //from [A,(1<<i)-1]
			ans += (1LL<<fr); //from [(1<<i),B]
			if(i==fr){
			    return ans;
			}
			ll x = A/(1LL<<fr); //cout << x << " " << i << " " << fr << endl;
			ll y = A%(1LL<<fr);
		    if(x) ans += (1LL<<fr)-y;
			ans += ((1LL<<(i-fr))-x-1) * (1LL<<fr);
			return ans;
		}
	}
}
int main(){
	cin >> A >> B;
	cout << C(A,B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long X, std::vector<long long> b, std::vector<long long> l, std::vector<long long> u){
  ll lf=-1,rt=accumulate(b.begin(),b.end(),0LL);
  vector<pll> p;
  REP(N){
    p.push_back(pll(l[i]*b[i]+u[i]*(X-b[i]),i));
  }
  sort(p.begin(),p.end(),greater<pll>());
  vector<ll> sump;
  sump.push_back(0);
  REP(N){
    sump.push_back(sump.back()+p[i].first);
  }
  dump(p);
  dump(sump);
  ll bsum=0;
  REP(N){
    bsum+=b[i]*l[i];
  }
  while(lf+1<rt){
    ll mid=(lf+rt)/2;
    ll ans=0;
    if(mid%X)REP(N){
      ll sum=0;

      if(i<mid/X){
        sum=sump[mid/X+1]-p[i].first;
      }else{
        sum=sump[mid/X];
      }
      ll idx=p[i].second;
      if(mid%X<b[idx]){
        sum+=(mid%X)*l[idx];
      }else{
        sum+=(mid%X-b[idx])*u[idx]+b[idx]*l[idx];
      }
      ans=max(ans,sum);
      if(ans>=bsum)break;
    }
    else{
      ans=sump[mid/X];
    }
    if(ans>=bsum){
      rt=mid;
    }else{
      lf=mid;
    }
  }
  cout<<rt<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> b(N);
    std::vector<long long> l(N);
    std::vector<long long> u(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
        scanf("%lld",&l[i]);
        scanf("%lld",&u[i]);
    }
    solve(N, X, std::move(b), std::move(l), std::move(u));
    return 0;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,m;
  	cin>>a>>b>>c>>m;
  	while(b<=a){
    	b*=2;
      	m--;
    }
  	while(m--){
    	c*=2;
    }
  	c>b ? cout<<"Yes" : cout<<"No";
}

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

int main(){
    int arr[5];
    int res=0;
    for(int i=0;i<5;i++){
        cin>>arr[i];
        if(arr[i]==0){
            res=i+1;
        }
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 3580
N,A,B = map(int,input().split())
ans = []
for i in range(N+1):
    a = [] #各桁の数字を入れる
    for k in range(len(str(i))):
        I = str(i)
        a.append(int(I[k]))
    if A <= sum(a) <= B:
        ans.append(i)
print(sum(ans))

Measured memory_bytes: 3404
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n,l;
  cin >> n >> l;
  int total = 0;
  int cp;
  for (int i = 1; i <= n; ++i) {
    total += i + l - 1;
  }
  cp = total;
  // cout << total << endl;
  int ans = 10000000;
  int sub = 10000000;
  for (int i = 1; i <= n; ++i) {
    int tt = 0;
    for (int j = 1; j <= n; ++j) {
      if (j == i) continue;
      tt += l + j - 1;
    }
    // cout << tt << endl;
    if (sub > abs(total - tt)) {
      ans = tt;
      sub = abs(total - tt);
    }
    // ans = min(ans, abs(total - tt));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        hs: [usize; n],
    }
    let mut max_count = 0;
    let mut max_pos = 0;
    let mut count = 0;
    let mut pos = 0;
    for i in 0..n - 1 {
        if hs[i] >= hs[i + 1] {
            if count == 0 {
                pos == i;
            }
            count += 1;
        } else {
            if max_count < count {
                max_count = count;
                max_pos = pos;
            }
            count = 0;
        }
    }
    if max_count < count {
        max_count = count;
        max_pos = pos;
    }
    println!("{}", max_count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define N 200005
int n,m;
int l;
int head[N];
int ina[N], inb[N];
int x,y;
bool vis[N];
struct node
{
	int x,y,next;
}edge[2*N];
char s[N];
queue<int> q;
void add(int x,int y)
{
	l++;
	edge[l].x = x;edge[l].y = y;edge[l].next = head[x];
	head[x] = l;
}
bool top_sort()
{
	for (int i=1;i<=n;i++)
	{
		if (q.empty()) return 0;
		int u = q.front();
		q.pop();
		for (int p = head[u];p;p=edge[p].next)
		{
			if (s[u] == 'A') ina[edge[p].y]--; else inb[edge[p].y]--;
			if (!vis[edge[p].y] && (!ina[edge[p].y] || !inb[edge[p].y]))
			{
				q.push(edge[p].y);
				vis[edge[p].y] = 1;
			}
		}
	}
	return 1;
}
int main()
{
	//idea:由一个无效点推导出其他的无效点，如果最后还有点能构成一个环，那么就有解
	scanf("%d%d", &n, &m);
	scanf("%s", s+1);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d", &x, &y);
		add(x,y);
		add(y,x);
		if (s[x] == 'A') ina[y]++; else inb[y]++;
		if (s[y] == 'A') ina[x]++; else inb[x]++;
	}
	for (int i=1;i<=n;i++)
		if (!ina[i] || !inb[i]) 
		{
			q.push(i);
			vis[i] = 1;
		}
	if (!top_sort()) printf("Yes\n"); else printf("No\n");
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

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

	    int A=gi();
	    int B=gi();
	    int M=gi();
	    int[] a=new int[A];
	    int[] b=new int[B];

	    int ma=Integer.MAX_VALUE;
	    int mb=Integer.MAX_VALUE;
	    for (int i=0; i<A;i++) {
	    	a[i]=gi();
	    	if(ma>a[i])ma=a[i];
	    }
	    for (int i=0; i<B;i++) {
	    	b[i]=gi();
	    	if(mb>b[i])mb=b[i];
	    }
	    int min=ma+mb;
	    for (int i=0; i<M;i++) {
	    	int x=gi();
	    	int y=gi();
	    	int c=gi();
	    	int q=a[x-1]+b[y-1]-c;
	    	if(min>q)min=q;
	    }
//	    if (N<M) {
//	    	System.out.println("X");
//	    } else if (N>M) {
//	    	System.out.println("Y");
//	    }
	    System.out.println(min);
	}

	// s進数で表した時の桁数
	public static int NsinKeta(int n, int s) {
		if(n==0) return 1;

		int i=0;
		while(n!=0) {
			n=Math.floorDiv(n, s);
			i++;
		}

		return i;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 60168
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	vector<ll> dp(W);
	dp[0] = 1;
	getchar_unlocked();
	getchar_unlocked();
	rep1(w, W - 1) dp[w] = (getchar_unlocked() == '.' ? dp[w - 1] : 0);
	getchar_unlocked();

	rep1(h, H - 1) {
		dp[0] = (getchar_unlocked() == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (getchar_unlocked() == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
		getchar_unlocked();
	}
	printf("%d", dp[W - 1] % mod);

	Would you please return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int n,m;
int a[1110],b[1110];
int cost[110][110];
int edge[1100];

void print_all_cost(){
    rep(i,n){
        rep(j,n)cout << cost[i][j] << " ";cout << endl;
    }
    cout << endl;
}
void Warshall_Floyd(){

    for(int corner = 0;corner < n;corner++){
        for(int s = 0;s < n;s++){
            for(int t = 0;t < n;t++){
                if(cost[s][t] > cost[s][corner] + cost[corner][t]){
                    cost[s][t] = cost[s][corner] + cost[corner][t];
                }
            }
        }
    }
}

bool check_include_shortestpath(int x){
    int s = a[x],t = b[x];
    for(int i = 0;i < n;i++){
        if(cost[i][t] == cost[i][s] + edge[x])return true;
    }
    return false;
}
int main(void){
    cin >> n >> m;
    rep(i,110)rep(j,110){
        if(i == j)cost[i][j] = 0;
        else cost[i][j] = INT_MAX/3;
    }
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        cin >> edge[i];
        //cost[a[i]][b[i]] = cost[b[i]][a[i]] = edge[i];
        mins(cost[a[i]][b[i]],edge[i]);
        mins(cost[b[i]][a[i]],edge[i]);
    }
    //print_all_cost();
    Warshall_Floyd();
    //print_all_cost();
    int count = m;
    rep(i,m){
        if(check_include_shortestpath(i)){count--;}
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int k, s, x, y, z, ans = 0;
	cin >> k >> s;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			z = s - x - y;
			if (0 <= z && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,n1=0,n2=0,n4=0,n5=0;
  int C,D;
  cin >> A >> B;
  int x =0;
  for(int N=A;N<=B;N++){
 	n1=N%10;
    n2=(N/10)%10;
    n4=(N/1000)%10;
    n5=(N/10000)%10;
    C=n1+10*n2;
    D=n5+10*n4;
    if(C==D)
      x++;
  }
  cout << x << endl;
}
  
  

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

int main(int args, char *argv[])
{
  int c[3][3];

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> c[i][j];
    }
  }

  for (int i = 0; i < 2; i++)
  {
    int tmp = c[i][0] - c[i + 1][0];
    for (int j = 1; j < 3; j++)
    {
      if (tmp != c[i][j] - c[i + 1][j])
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  for (int i = 0; i < 2; i++)
  {
    int tmp = c[0][i] - c[0][i + 1];
    for (int j = 1; j < 3; j++)
    {
      if (tmp != c[j][i] - c[j][i + 1])
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    long long int n, a, b;
    cin >> n >> a >> b;
    long long int ans = 0;
    ans += n/(a+b)*a;
    n = n%(a+b);
    if(n<=a){
        ans += n;
    }else{
        ans += a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
def checkConnum(n, x):
    cnt = 0
    for i in range(1,n+1):
        j = i + 1
        k = j + 1
        while((i+j+k) <= x and j <= n ):  
            while((i+j+k) <= x and k <= n):
                if((i+j+k) == x ):
                    cnt += 1
                k+= 1
            j += 1
            k = j + 1

    return cnt

def ansOutPut(ans, ansnum):
    for i in range(ansnum):
        print(ans[i])

N, X = map(int, input().split())
ans = []
while(N != 0 or X != 0 ):
    ans.append(checkConnum(N,X))
    N, X = map(int, input().split())

ansOutPut(ans, len(ans))



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  
  ll arr[n+1];
  for(ll i =1;i<=n;i++)
    cin>>arr[i];
  for(ll i =1;i<=n;i++)
    arr[i] = arr[i] - i;
  
  sort(arr+1,arr+n+1);
  ll b;

  b = arr[n/2 + 1];
  

  //cout<<b<<" "<<c<<endl;
  ll cost1 = 0;
  //ll cost2 =0;
  for(ll i =1;i<=n;i++)
    {cost1 = cost1 + abs(arr[i] - b);
    //cost2 = cost2 + abs(arr[i] - c);}
    }
  cout<<cost1;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int N;
    scanf("%d",&N);

    if( N >= 1000 ){
        printf("ABD\n");
    }else{
        printf("ABC\n");
    }
    return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	int N;
	cin>>N;
	N--;

	ll ans=0;

	rep(i,N+1){
		if(i==0)continue;
		ans+=N/i;
	}

	cout<<ans<<_n;
}


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


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#define MAX 100
#define NIL -1
using namespace std;

struct Node {
	int parent, left, right, depth, height;
};

Node node[MAX];

void setDepth(int u, int p);
int setHeight(int u);

int main() {
	int i, j, n, id, tmp, root;
	cin >> n;
	for (i = 0; i < n; i++) {
		node[i].parent = NIL;
		node[i].left = NIL;
		node[i].right = NIL;
	}

	for (i = 0; i < n; i++) {
		cin >> id;
		cin >> node[id].left >> node[id].right;
		node[node[id].left].parent = id;
		node[node[id].right].parent = id;
	}

	root = 0;
	while (node[root].parent != NIL) {
		root = node[root].parent;
	}
	setDepth(root, 0);
	setHeight(root);

	for (i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << node[i].parent << ", sibling = ";
		if (i == root)cout << -1;
		else if (node[node[i].parent].right != i)cout << node[node[i].parent].right;
		else if (node[node[i].parent].left != i)cout << node[node[i].parent].left;
		cout << ", degree = " << (node[i].left != NIL) + (node[i].right != NIL);
		cout << ", depth = " << node[i].depth;
		cout << ", height = " << node[i].height << ", ";
		if (i == root)cout << "root";
		else if (node[i].left != NIL || node[i].right != NIL)cout << "internal node";
		else cout << "leaf";
		cout << endl;
	}

	return 0;
}

void setDepth(int u, int p) {
	node[u].depth = p;
	if (node[u].right != NIL)setDepth(node[u].right, p + 1);
	if (node[u].left != NIL)setDepth(node[u].left, p + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (node[u].right != NIL)h1 = setHeight(node[u].right) + 1;
	if (node[u].left != NIL)h2 = setHeight(node[u].left) + 1;
	return node[u].height = max(h1, h2);
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 || b % 2 || c % 2) {
    cout << 0 << endl;
    return 0;
  }
  if (a == b && b == c) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    ll aa = a / 2;
    ll bb = b / 2;
    ll cc = c / 2;
    a = bb + cc;
    b = cc + aa;
    c = aa + bb;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()
    v = f()

    ans = 0
    for take in range(1, min(k+1, n+1)):
        r_op = k - take
        for left in range(0, take+1):
            right = take - left
            nums = v[:left] + v[n- right:]
            nums = sorted(nums)
            cur_ans = sum(nums) 

            for i in range(r_op):
                if i<len(nums) and nums[i]<0:
                    cur_ans += abs(nums[i])

            ans = max(ans, cur_ans)
    
    print(ans)

            


solve()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ret;
    for (int i = 0; i <= N / R; ++i) {
        for (int j = 0; j <= N / G; ++j) {
            ll rest = N - i * R - j * G;
            if (0 <= rest && rest % B == 0)
                ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    n = II()
    a = list(map(str, input().split()))
    return n, a


def solve(n, a):
    b = collections.deque([])
    if n % 2 == 0:
        for i, ele in enumerate(a):
            if i % 2 == 0:
                b.append(ele)
            else:
                b.appendleft(ele)
    else:
        for i, ele in enumerate(a):
            if i % 2 == 0:
                b.appendleft(ele)
            else:
                b.append(ele)

    ans = " ".join(list(b))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 30176
import sys
from itertools import combinations_with_replacement as cwr
input = sys.stdin.readline

def dfs(n,m):
    adj = {}
    for i in range(1,m+1):
        adj[i] = [j for j in range(i,m+1)]
    
    stack = [[i] for i in range(1,m+1)]
    combs = []
    while stack:
        node = stack.pop()
        if len(node) == n:
            combs.append(node)
        else:
            for child in adj[node[-1]]:
                cand = node+[child]
                stack.append(cand)
    return combs


N,M,Q = map(int,input().split())
A,B,C,D = [],[],[],[]
for i in range(Q):
    a,b,c,d = map(int,input().split())
    a,b = a-1, b-1
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

ans = 0
combs = dfs(N,M)
#combs = cwr(range(1,M+1),N)
# print(combs)
ans = [0]*(len(combs))
for i,comb in enumerate(combs):
    for a,b,c,d in zip(A,B,C,D):
        if comb[b] - comb[a] ==c:
            ans[i] += d
print(max(ans))



Measured memory_bytes: 26468
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

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

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

	int n;
	cin >> n;
	vector<int> b(n - 1);
	for (int i = 0; i < n - 1; i++) cin >> b[i];
	int answer = b[0];
	int prv = b[0];
	for (int i = 1; i < n - 1; i++) answer += min(b[i - 1], b[i]);
	answer += b[n - 2];
	cout << answer;

	return 0;
}


Measured memory_bytes: 256
import sys
stdin=sys.stdin

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

S=input()
A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if(S=='z'):
    print('a')
else:
    inds=A.index(S)
    print(A[inds+1])


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

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
            String[] s = in.readLine().split(" ");
            double x1 = Double.parseDouble(s[0]);
            double x2 = Double.parseDouble(s[1]);
            double y1 = Double.parseDouble(s[2]);
            double y2 = Double.parseDouble(s[3]);

            System.out.printf("%.8f", Math.sqrt(Math.pow((y1 - x1), 2.0) + Math.pow((y2 - x2), 2.0)));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24776
import sys

n=int(sys.stdin.readline())

r=[int((sys.stdin.readline().rstrip())) for _ in range(n) ]


maxv=int(-20000000000)
minv=r[0]

for i in range(1,n):
    maxv=max(maxv,r[i]-minv)
    minv=min(minv,r[i])

print(maxv)




Measured memory_bytes: 13620
use std::io::stdin;

fn main(){
    let n = getvec()[0];
    let m = 1_000_000_007;
    let ans = (1..n+1).fold(1, |acc, x|{acc * x % m});
    println!("{}", ans)
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<i64>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

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

using namespace std;

int main(){
	int N = 0, L = 0;
	
	cin >> N >> L;
	
	int ans = 0;
	if(L < 0){
		if(L + N > 0){
			for(int i = 1; i < N+1; i++){
				ans += L + i - 1;
			}
		}else{
			for(int i = 1; i < N; i++){
				ans += L + i - 1;
			}
		}
	}else{
		for(int i = 2; i < N + 1; i++){
			ans += L + i - 1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#ifdef DEBUG_ON
    freopen("input", "r", stdin);
#endif

    std::string str;
    std::cin >> str;
    int res = 0;
    for (int i = 1; i < str.length(); ++i) {
        if (str[i] != str[i - 1]) {
            ++res;
        }
    }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
bool comp(ll &a,ll &b){
  return a>b;
}
int main(){
  int n,m;
  ll x[1010],y[1010],z[1010];
  cin>>n>>m;
  rep(i,n){
    cin>>x[i]>>y[i]>>z[i];
  }
  ll a[1010],b[1010],c[1010],d[1010];
  ll res=0;
  rep(i,(1<<3)){
    rep(j,n){
      if(i&1) a[j]=-x[j];
      else a[j]=x[j];
      if(i>>1&1) b[j]=-y[j];
      else b[j]=y[j];
      if(i>>2&1) c[j]=-z[j];
      else c[j]=z[j];
      d[j]=a[j]+b[j]+c[j];
    }
    sort(d,d+n,comp);
    ll sum=0;
    rep(i,m){
      sum+=d[i];
    }
    res=max(res,sum);
  }
  prin(res);
  
      


  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int a,b; // Your code here!
    scanf("%d %d",&a ,&b);
    if ( a>b ){
        printf("a > b\n");
    } else if (a<b){
        printf("a < b\n");
    } else{
        printf("a == b\n");
    }
}




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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll a, b;
	cin>>a>>b;
	ll g = __gcd(a, b);
	int ans = 1;
	for(ll n = 2; n*n <= g; n++){
		if(g%n)continue;
		while(g%n == 0){
			g /= n;
		}
		ans++;
	}
	if(g > 1)ans++;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256