akhauriyash/Code-Regression huggingface dataset:
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
int xchanges[] = {-1, +1, 0, 0};
int ychanges[] = {0, 0, -1, +1};

void solve(){
    int n, m;
    cin>>n>>m;
    int sx, sy, ex, ey;
    cin>>sx>>sy>>ex>>ey;
    --sx, --ex, --sy, --ey;
    vector<string> vec(n);
    for(int i = 0; i< n; i++)
        cin>>vec[i];

    vector<vector<int>> val(n, vector<int>(m, INT_MAX));
    deque<pair<int, pair<int, int>>> q;
    q.push_front({0, {sx, sy}});
    while(!q.empty()){
        pair<int, pair<int, int>> temp = q.front();
        q.pop_front();
        int x = temp.second.first, y = temp.second.second;
        for(int i = 0; i < 4; i++){
            int nx = x + xchanges[i], ny = y + ychanges[i];
            if(nx >= 0 && ny >= 0 && nx < n && ny < m && vec[nx][ny] != '#'){
                if(val[nx][ny] > temp.first){
                    val[nx][ny] = temp.first;
                    q.push_front({temp.first, {nx, ny}});
                }
            }
            }
        for(int i = -2; i <= 2; i++)
            for(int j = -2; j <= 2; j++){
                int nx = i+x, ny = j+y;
                if(nx >= 0 && ny >= 0 && nx <n && ny < m && vec[nx][ny] != '#'){
                    if(val[nx][ny] > temp.first+1){
                        val[nx][ny] = temp.first+1;
                        q.push_back({temp.first+1, {nx, ny}});
                    }
                }
            }
    }
    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j < m; j++)
    //         cout<<val[i][j]<<" ";
    //     cout<<"\n";
    // }
    if(val[ex][ey] == INT_MAX)
        val[ex][ey] = -1;
    cout<<val[ex][ey];
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

int main() {
  int n;
  cin >> n;

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  int sum_p = accumulate(p.begin(), p.end(), 0);
  int max_p = *max_element(p.begin(), p.end());

  int ans = sum_p - max_p + (int)(max_p / 2);
  cout << ans << endl;

  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int s;
    cin >> s;
    int s1 = s / 100;
    int s2 = s % 100;
    bool ok1 = false;
    bool ok2 = false;
    if(0 < s1 && s1 <= 12) ok1 = true;
    if(0 < s2 && s2 <= 12) ok2 = true;
    if(ok1 && ok2){
        cout << "AMBIGUOUS" << endl;
        return;
    }
    if(!ok1 && !ok2){
        cout << "NA" << endl;
        return;
    }
    if(ok1){
        cout << "MMYY" << endl;
        return;
    }
    if(ok2){
        cout << "YYMM" << endl;
        return;
    }

	return;
}

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

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#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 ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	FOR(i,0,n)cin >> p[i];
	sort(ALL(p));
	int ans = 0;
	FOR(i,0,n-1)ans += p[i];
	ans += p[n-1]/2;
    ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int n; cin >> n;
	int d[51];
	REP(i, n)cin >> d[i];
	int ans = 0;
	for (int i = 0; i < n-1; ++i) {
		for (int j = i + 1; j < n; ++j) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s = a;
  sort(s.rbegin(), s.rend());
  rep(i,n) {
    int ans = s[0];
    if (s[0] == a[i]) ans = s[1];
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>
#define LEN 1000005
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head, tail, n;
 
void enqueue(P);
P dequeue();
 
int main(){
  int elaps = 0, c = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
 
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
 
  while(head != tail){
    u = dequeue();
  u.t = u.t - q;
  if(u.t <= 0){
    printf("%s %d\n",u.name, (u.t+q+(elaps*q)-c));
    c = c - u.t;
  } else{
  enqueue(u);
  }
    elaps++;
  }
   
  return 0;
}
 
 
void enqueue(P x){
  Q[tail] = x;
  tail++;
}
 
P dequeue(){
  head++;
  return Q[head-1];
}

Measured memory_bytes: 21076
import java.util.Scanner;
		 
		public class Main {
			
			public static void main(String[] args) {
				
				Scanner sc = new Scanner(System.in);
				long n = sc.nextLong();
				long m = sc.nextLong();
				long x = 1000000000+7;
				
				long kai = 1;
				long amari = 0;
				for(int i = 1; i <= n; i++) {
					kai *= i;
					if(kai > x) {
						kai = kai % x;
					}
				}
				for(int i = 1; i <= m; i++) {
					kai *= i;
					if(kai > x) {
						kai = kai % x;
					}
				}
				
				if(Math.max(n, m) - Math.min(n, m) > 1) {
					System.out.println(0);
				} else if(n == m) {
					System.out.println(kai * 2 % x);
				} else {
					System.out.println(kai % x);
				}
			}
		}

Measured memory_bytes: 23636
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>

//https://atcoder.jp/contests/abc160/tasks/abc160_c

int main()
{
    std::ios::sync_with_stdio(false); // toggler av synkronisjon mellom c og c++ data streams. kan ikke blade de etter skrudd av
    std::cin.tie(NULL);               //gj;r at man ikke venter på cout og de can printe samtidig tror jeg

    //linjen er opp til 100. det er en linje p[ lengde hundre med hus p[ bare de nevte stedene]]

    int fullDist, houseNum;
    std::cin >> fullDist >> houseNum;

    int maxDiff = 0;
    int lastDist = 0;

    int firstDiff = -1;
    for (int i = 0; i < houseNum; i++)
    {
        int houseDist;
        std::cin >> houseDist;
        int newDiff = houseDist - lastDist;

        if (firstDiff == -1)
        {
            firstDiff = newDiff;
        }

        maxDiff = std::max(newDiff, maxDiff);
        lastDist = houseDist;
    }

    int newDiff = (fullDist - lastDist) + firstDiff;
    maxDiff = std::max(newDiff, maxDiff);

    std::cout << (fullDist - maxDiff) << "\n";
}


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

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    ll n,k;
    cin >> n >> k;
    double p[n];
    inrep(n,p);

    rep(i,0,n){
	p[i] = (1+p[i])*p[i]/2/p[i];
    }

    double ans = 0;
    double tmp = 0;
    rep(i,0,k)ans += p[i];
    tmp = ans;
    
    rep(i,k,n){
	tmp -= p[i-k];
	tmp += p[i];	
	ans =max(ans,tmp);
    }
    printf("%.10f\n",ans);
    return  0;
}


Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))
H.append(1000000001)

max = H[0]
for i in range(N):
    if max >= H[i+1] + 2:
        print('No')
        break
    if max < H[i+1]:
        max = H[i+1]
        
else:
    print('Yes')
        

Measured memory_bytes: 14252
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int s;
	set<int> se;
	cin >> s;
	int cnt = 1;
	while (se.find(s) ==se.end()) {
		se.insert(s);
		if (s % 2 == 0) {
			s /= 2;
		}
		else {
			s = s * 3 + 1;
		}
		cnt++;
		
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
LL A,B,C;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>A>>B>>C;
    C=min(C,A+B+1);
    cout<<B+C<<endl;
    return 0;
}


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

class Main{
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long X = Long.parseLong(sc.next());
      long Y = Long.parseLong(sc.next());
      long a = X;
      long cnt = 0;
      while(a<=Y){
        a*=2;
        cnt++;
      }
      System.out.println(cnt);
  }
}

Measured memory_bytes: 21972
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.regex;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable long MOD = 1000000007;


auto solve(long N) {
    const ACGT = ["A", "G", "C", "T"];
    const ACGT3 = cartesianProduct(ACGT, ACGT, ACGT).map!"a[0] ~ a[1] ~ a[2]".array;

    long[][string] dp;
    foreach (s; ACGT3)
        dp[s] = new long[](N);
    
    dp["CCA"][0] = 1;
    dp["CCG"][0] = 1;
    dp["CCC"][0] = 1;
    dp["CCT"][0] = 1;

    foreach (i; 1 .. N) {
        foreach (s, nc; cartesianProduct(ACGT3, ACGT)) {
            if (matchFirst(s, `.AG`.regex) && nc == "C") continue;
            if (matchFirst(s, `A.G`.regex) && nc == "C") continue;
            if (matchFirst(s, `.GA`.regex) && nc == "C") continue;
            if (matchFirst(s, `.AC`.regex) && nc == "G") continue;
            if (matchFirst(s, `AG.`.regex) && nc == "C") continue;

            const ns = s[1 .. $] ~ nc;
            dp[ns][i] += dp[s][i - 1];
            dp[ns][i] %= MOD;
        }
    }

    return ACGT3.map!(s => dp[s][N - 1]).reduce!((a, b) => (a + b) % MOD);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N);
    else
        solve(N).writeln;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
  for(int i=0;i<s.size();i++)
    for(int j=0;j<t.size();j++)
      dp[i+1][j+1]=max(max(dp[i+1][j],dp[i][j+1]),dp[i][j]+(s.at(i)==t.at(j)?1:0));
  int i=s.size();
  int j=t.size();
  vector<bool> sb(s.size(),0);
  while(dp[i][j]>0){
    if(dp[i-1][j]<dp[i][j]&&dp[i][j-1]<dp[i][j]){
      sb.at(i-1)=1;
      i--;
      j--;
    }else if(dp[i-1][j]<dp[i][j])
      j--;
    else
      i--;
  }
  for(int i=0;i<s.size();i++)
    if(sb.at(i))
      cout<<s.at(i);
  cout<<endl;
}

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

signed main(){
	int n; cin >> n;
	int count = 0;
	for (int i=1; i<=n; ++i){
		int v; cin >> v;
		if (i%2){
			if (v%2)
				count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1005;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001LL;
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int h,w,k;
bool vis[N*N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void solve(){
	range(i,0,h){
		range(j,0,w){
			vis[i*j+(h-i)*(w-j)]=1;
		}
	}
}
int main(){
//	freopen("ex.in","r",stdin);
	h=read();w=read();k=read();
	solve();
	if(vis[k]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

string S;
int ct = 0;

void Chain(int v){
	
	if(v < 0) v = 0;
	if(S.length() <= 1) return;
	if(v >= S.length() - 1) return;
	
	//printf("v = %d\n", v);
	
	if(S[v] != S[v+1]){
		//printf("deleted: %d(\"%c\") and %d(\"%c\")\n", v, S[v], v+1, S[v+1]);
		S.erase(S.begin() + v);
		S.erase(S.begin() + v);
		ct += 2;
		//printf("S: %s\n", S.c_str());
		Chain(v - 1);
	}else{
		Chain(v + 1);
	}
	
}

int main(){
	
	char in[100000];
	int l;
	
	scanf("%s", in);
	S = in;
	l = S.length();
	
	Chain(0);
	
	printf("%d\n", ct);
	
	return 0;
	
}


Measured memory_bytes: 512
n = int(input())

monster_list = [ int(v) for v in input().split() ]
aaaa_list = [ int(v) for v in input().split() ]

tottal_battle = 0
for i in range(n):
    battle = min(aaaa_list[i],monster_list[i])
    if aaaa_list[i] >= monster_list[i]:
        monster_list[i] = 0
        aaaa_list[i] -= battle
    else:
        aaaa_list[i] = 0
        monster_list[i] -= battle
    tottal_battle += battle
    battle = min(aaaa_list[i],monster_list[i+1])
    if aaaa_list[i] >= monster_list[i+1]:
        monster_list[i+1] = 0
        aaaa_list[i] -= battle
    else:
        aaaa_list[i] = 0
        monster_list[i+1] -= battle
    tottal_battle += battle

print(tottal_battle)

Measured memory_bytes: 82020
#include <bits/stdc++.h>
#define int long long
const int MOD = 1e9 + 7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 105, maxk = 1e5 + 5;

int n, k, a[maxn], dp[maxn][maxk];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    dp[0][k] = 1;
    if(k > 0)
        dp[0][k - 1] = -1;
    for(int i = 0; i <= n; i++)
        for(int j = k; j >= 0; j--)
        {
            dp[i][j] += dp[i][j + 1];
            dp[i][j] %= MOD;
            dp[i][j] += MOD;
            dp[i][j] %= MOD;
            assert(dp[i][j] >= 0);
            if(!dp[i][j])
                continue;
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
            if(j > a[i])
            {
                dp[i + 1][j - a[i] - 1] -= dp[i][j];
                dp[i + 1][j - a[i] - 1] %= MOD;
                dp[i + 1][j - a[i] - 1] += MOD;
                dp[i + 1][j - a[i] - 1] %= MOD;
            }
        }
    cout << dp[n][0] << "\n";
    return 0;
}

Measured memory_bytes: 83292
#include<bits/stdc++.h>
using namespace std;
int n,d,x;
int a[101];
int f[101];
int ans;
int main()
{
	cin >>n >>d >>x;
	for (int i=1;i<=n;i++)
	{
	    cin >>a[i];
	    int t=0;
	    while((t*a[i]+1)<=d)
	    {
	    	f[t*a[i]+1]++;
	    	t++;
		}
    }
    for (int i=1;i<=d;i++)
        if (f[i]>=1)
        {
            ans+=f[i];
        }
    cout <<ans+x;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N, A, B, C, D = map(int, input().split())
S = input()

#hunuke

h = S[A-1:D+1].count('##')
m3 = S[B-2:D+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 != 0 and h == 0:
        print('Yes')
    else: print('No')
    


Measured memory_bytes: 43244
n,x = map(int,input().split())
l = 2*n-1
d = n-x
if 2 <= x <= l-1:
    print("Yes")
    ans = []
    for i in range(l):
        ans.append((l-d+i)%l+1)
    for i in ans:
        print(i)
else:
    print("No")

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

using namespace std;

int main() {
	long long a, b, x;

	scanf("%lld", &x);

	for (a = -1000; a <= 1000; a++) {
		for (b = -1000; b <= 1000; b++) {
			if (a * a * a * a * a - b * b * b * b * b == x) {
				printf("%lld %lld\n", a, b);
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3792
h, w = map(int, input().split())

A = []
A.append(['.'] * (w + 2))
for i in range(h):
    H = [str(i) for i in input()]
    A.append(['.'] + H + ['.'])
A.append(['.'] * (w + 2))

ans = 'Yes'

for i in range(h):
    for j in range(w):
        if A[i][j] == '#':
            if A[i - 1][j] == '.' and A[i + 1][j] == '.' and A[i][j - 1] == '.' and A[i][j + 1] == '.':
                ans = 'No'
                break

print(ans)

Measured memory_bytes: 3064
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		s: Chars,
	}

	let inf = 999999999999999usize;

	let mut ans = inf;
	for i in 0..s.len()-1 {
		if s[i] != s[i+1] {
			ans = min(ans, max(i+1, s.len()-i-1));
		}
	}
	if ans == inf {
		println!("{}", s.len());
	}
	else {
		println!("{}", ans);
	}
}



Measured memory_bytes: 2440
import math
import fractions

A,B,C,D = map(int, input().strip().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

ans = 0
lcm = lcm_base(C,D)
c_num = B//C - (A-1)//C 
d_num = B//D - (A-1)//D
diff = B//lcm - (A-1)//lcm

print(B-A+1-(c_num+d_num-diff))


Measured memory_bytes: 5048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod=1e9+7;
static const ll INF=1LL<<50;
using namespace std;

int main() {
	int n,k;
  cin>>n>>k;
  if(k==1)cout<<"0"<<endl;
  else cout<<n-k<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                          

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

   const int N = S.size();
   int K = N;
   for(int l=(N-1)/2, r=N/2; l>=0; --l, ++r){
      if(S[l]!=S[N/2] || S[r]!=S[N/2]){
         std::cout << r << std::endl;
         return 0;
      }   
   }   

   std::cout << N << std::endl;
   
   return 0;
}

Measured memory_bytes: 512
n = int(input())

a = list(map(int, input().split()))

count = 0
while True:
  evens = list(filter(lambda i: i % 2 == 0, a))
  if len(evens) == len(a):
    a = list(map(lambda i: int(i/2), a))
    count += 1
  else:
    break

print(count)

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

void trace(int A[],int N){
  for(int i=0;i<N;i++){
    if(i>0)cout<<" ";
    cout<<A[i];
  }
  cout<<"\n";
}

void insertionSort(int A[],int N){
  for(int i=1;i<N;i++){
    int v=A[i];
    int j=i-1;
    while(j>=0&&v<A[j]){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
  
}


int main()
{
  int n,A[1000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  trace(A,n);
  insertionSort(A,n);

  

  return 0;
}
    



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

int main() {
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2, N / 2))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}

ll dp[3001][3001];
ll sum[2][3001];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, n)dp[0][i] = 1;
  sum[0][0] = dp[0][0];
  FOR(i, 1, n+1)sum[0][i] = (sum[0][i-1] + dp[0][i] ) % mod;
  FOR(i, 1, n){
    rep(j, n){
      if(s[i-1] == '<'){
        dp[i][j] = (dp[i][j] + sum[0][n-i] - sum[0][j]) % mod;
      }else{
        dp[i][j] = (dp[i][j] + sum[0][j]) % mod;
      }
      if(dp[i][j] < 0)dp[i][j] += mod;
      sum[1][j] = dp[i][j];
      if(j > 0)sum[1][j] = (sum[1][j-1] + sum[1][j]) % mod;
    }
    swap(sum[0], sum[1]);
  }
  cout << dp[n-1][0] << endl;
	return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
    int tmp; cin >> tmp;
    int num[4];
    REP(i,4){
        num[i] = (tmp / (int)pow(10,3-i)) % 10;
    }
    REP(i,8){
        int first = num[0];
        REP(j,3){
            if(i>>j & 1){
                first += num[j+1];
            }else{
                first -= num[j+1];
            }
        }
        if(first == 7){
            cout << num[0];
            REP(j,3){
                if(i>>j & 1){
                    cout << "+";
                }else{
                    cout << "-";
                }
                cout << num[j+1];
            }
            cout << "=7" << endl;
            break;
        }
    }

}

Measured memory_bytes: 256
N, M = gets.chomp.split(' ').map(&:to_i)

if M == 0
  puts ('0 0')
  exit
end

hash = {}
M.times do
  pi, si = gets.chomp.split(' ')
  if hash.has_key?(pi)
    if si == 'AC' || hash[pi][:ac]
      hash[pi][:ac] = true
    else
      hash[pi][:wa_count] += 1
    end
  else
    if si == 'AC'
      hash[pi] = { ac: true, wa_count: 0 }
    else
      hash[pi] = { ac: false, wa_count: 1 }
    end
  end
end

ac_count = hash.count { |_, v| v[:ac] }
wa_count = hash.inject(0) { |a, b| a += (b[1][:ac] ? b[1][:wa_count] : 0) }

puts "#{ac_count} #{wa_count}"


Measured memory_bytes: 43004
#include<stdio.h>
int main()
{
    int a, b, i;
    scanf("%d", &a);
    while (a != 0){
        for (i = 0; i < 9; i++){
            scanf("%d", &b);
            a -= b;
        }
        printf("%d\n", a);
        scanf("%d", &a);
    }
    return 0;
}

Measured memory_bytes: 2576
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin()
#define en end()
#define vvl(n,m) vector<vector<ll> > a( n , vector<ll> (m))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = -1000000000000000, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 
ll countPairs(ll arr[], ll n) 
{ 
    map<ll, ll> map; 
    for (ll i = 0; i < n; i++) {
        if (map.find(arr[i]-i) == map.end()) { 
            map[arr[i]-i] = 1; 
        } 
        else { 
            map[arr[i]-i]++; 
        } 
    }
    ll res = 0; 
    for (auto x : map) { 
        ll cnt = x.second; 

        res += ((cnt * (cnt - 1)) / 2); 
    } 
  
    return res; 
} 
ll findSubarraySum(ll arr[], ll n, ll sum) 
{ 
    unordered_map<ll, ll> prevSum; 
  
    int res = 0; 
  
    int currsum = 0; 
  
    for (int i = 0; i < n; i++) { 
        currsum += arr[i]; 
        if (currsum == sum)  
            res++;         
  
        if (prevSum.find(currsum - sum) !=  
                                  prevSum.end())  
            res += (prevSum[currsum - sum]);
        prevSum[currsum]++; 
    } 
  
    return res; 
} 
ll sod(ll x){
    ll r,sum=0;
    while(x>0){
        r=x%10;
        x/=10;
        sum+=r;
    }
    return sum;
}
long long modpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    fast
    ll n,i;
    cin>>n;
    ll a[n],sum=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll r=1e9+7;
    ll s=(1e9+8)/2;
    ll z=((sum%r)*(sum%r))%r;
    ll x=0;
    for(i=0;i<n;i++){
        x=(x+(a[i]*a[i])%r)%r;
    }
    x=((z-x)%r+r)%r;
    x=(x*s)%r;
    cout<<x;
}

Measured memory_bytes: 5184
#include <stdio.h>
int main(){
	int a,b[10000],c;
	scanf("%d",&a);
	for (int i = 0; i < a; ++i)
	{
		scanf("%d",&b[i]);
	}
	for (int j = 0; j < a; ++j)
	{
		while(b[j]%2==0)
		{
			c=c+1;
			b[j]=b[j]/2;
		}
	}
	printf("%d\n",c);
}

Measured memory_bytes: 256
a,b= map(int,input().split())

l = 1

c = [1]
d = [1]

for i in range(50):
	c.append(2*c[-1]+3)
	d.append(2*d[-1]+1)
k = 0
while True:
	if a == 0:
		k += 1
		break
	elif b==1:
		break
	elif c[a] // 2 == b:
		k += d[a-1]
		break
	elif c[a] // 2 > b:
		a -= 1
		b -= 1
	elif c[a] // 2 + 1 == b:
		k += 1 + d[a-1]
		break
	elif c[a] // 2 + 1 < b and c[a] != b:
		a -= 1
		k += d[a]+1
		b -= c[a]+2
	else:
		k += d[a]
		break


print(k)

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

int main(){
  int N;
  bool flag;
  cin >>N;
  flag=false;
  for(int i=0;i<=(N-(N%7))/7;i++){
    if((N-7*i)%4==0){
      flag=true;
    }
  }
  if(flag){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
import array

n, p = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

ans = []
S = array.array('Q', (0,))

for x in X:
    S.append(S[-1] + x)

for t in range(1, n+1):
    tmp = 5 * S[n] + (t + n) * p
    cur = n - t * 2
    while cur > 0:
        tmp += 2 * S[cur]
        cur -= t

    ans.append(tmp)

print(min(ans))

Measured memory_bytes: 26832
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim()
{
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++)
  {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1)
  {
    minv = INFTY;
    u=-1;

    // 黒以外のやつから最小を探す
    for(int i=0;i<n;i++)
    {
      if(minv>d[i] && color[i] != BLACK)
      {
        u=i;
        minv=d[i];
      }
    }

    // 全部黒だったらループ終了
    if(u==-1)break;

    color[u] = BLACK;

    // u番目とつながるものに値を与える(黒以外)
    for(int v=0;v<n;v++)
    {
      if(color[v] != BLACK && M[u][v] != INFTY)
      {
        if(d[v] > M[u][v])
        {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(int i=0;i<n;i++)
  {
    if(p[i]!=-1) sum += M[i][p[i]];
  }
  return sum;
}

int main()
{
  cin >> n;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      int e;
      cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  cout << prim() << endl;
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    int n = s.size();
    std::vector<int> dig(n);
    for (int i = 0; i < n; i++) dig[i] = s[i] - '0';
    auto chmin = [](int &a, int b) { return a = std::min(a, b); };
    std::vector<std::vector<int>> dp(n + 2, std::vector<int>(3, -1));
    auto func = [&](const auto &self, int t, int state) -> int {
        if (t >= n) return ~state&1 ? 0 : 1e9;
        if (dp[t][state] != -1) return dp[t][state];
        int ret = 1e9;
        if (state == 0) {
            chmin(ret, self(self, t + 1, 0) + dig[t]);
            chmin(ret, self(self, t + 1, 1) + dig[t] + 1);
        }
        if (state == 1) {
            chmin(ret, self(self, t + 1, 0) + 10 - dig[t]);
            chmin(ret, self(self, t + 1, 1) + 9 - dig[t]);
        }
        if (state == 2) {
            chmin(ret, self(self, t + 1, 2) + dig[t]);
            chmin(ret, self(self, t + 1, 1) + dig[t] + 1);
        }
        return dp[t][state] = ret;
    };
    std::cout << std::min(func(func, 0, 2), 1 + func(func, 0, 1)) << std::endl;
    return 0;
}


Measured memory_bytes: 137988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int L,R;
  cin >> L >> R;
  int ans=2018;
  if(R-L>=2018)ans=0;
  else {
    int q=L/2019;
    L-=q*2019;
    R-=q*2019;
    rep2(i,L,R) {
      rep2(j,i+1,R+1) ans=min(ans,i*j%2019);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
#import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    #return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    #return reduce(fractions.gcd, numbers)

K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            abc_gcd = gcd_list([a,b,c])
            #print(a,b,c,abc_gcd)
            ans += abc_gcd

print(ans)

Measured memory_bytes: 74708
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms

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

#define int     long long int
#define pii     pair<int, int>
#define vi      vector<int>
#define vii     vector<pair<int, int>>
#define pb      push_back
#define all(a)  (a).begin(),(a).end()
#define f       first
#define s       second
#define endl    '\n'
#define mod     1000000007    		

const int N = 2E5 + 5, M = 2E5 + 5;
int n, m, k ;
int a[N], b[M] ;


void solve()
{
	cin >> n >> m >> k ;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> a[i] ;
		a[i] += a[i - 1] ;
	}
	for(int i = 1 ; i <= m ; i++)
	{
		cin >> b[i] ;
		b[i] += b[i - 1] ;
	}
	int ans = 0 ;
	for(int i = 0 ; i <= n ; i++)
	{
		if(a[i] > k)
			break ;
		int ind = upper_bound(b, b + m + 1, k - a[i]) - b;
		ans = max(ans, ind + i - 1) ;
	}
	cout << ans << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 6740
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define INT long long
#define MOD 1000000007

using namespace std;
int n, a[100010], t, ans;
int main()
{
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; i++ )
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= n ; i++ )
        if( a[a[i]] == i ) ans++;
    printf("%d\n", ans/2);
}


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

int count(int n, int x) {
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i+1; j <= n; j++)
            for (int f = j+1; f <= n; f++)
                if (i+j+f == x)  ans++;
    return ans;
}

int main() {
    int n, x;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        cout << count(n,x) << endl;
    }
}


Measured memory_bytes: 3116
# -*- coding: utf-8 -*-

R,C,K = map(int, input().split())

items = [[0 for _ in range(C+1)] for _ in range(R+1)]
for i in range(K):
  r,c,v = map(int, input().split())
  items[r][c] = v

DP1 = [0 for _ in range(C+1)]
DP2 = [0 for _ in range(C+1)]
DP3 = [0 for _ in range(C+1)]
for r in range(1,R+1):
  for c in range(1,C+1):
    item = items[r][c]
    DP1[c] = max(DP3[c]+item,DP1[c-1])
    DP2[c] = max(DP1[c],DP2[c-1],DP1[c-1]+item)
    DP3[c] = max(DP2[c],DP3[c-1],DP2[c-1]+item)
        
print(DP3[C])

Measured memory_bytes: 149328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll c[30],s[400][30],las[30];

int main()
{
	int D;
	cin >> D;
	rep(i,26)
	{
		cin >> c[i];
	}
	rep(i,D)
	{
		rep(j,26)
		{
			cin >> s[i][j];
		}
	}
	for (ll i = 0; i < D; ++i)
	{
		ll best = -1 * 1e10;
		ll bestv = 0;
		rep(j,26)
		{
			ll tmp = 0;
			tmp += s[i][j];
			rep(k,26)
			{
				if (k != j)
				{
					tmp -= c[k] * (i+1 - las[k]);
				}
			}
			if (tmp > best)
			{
				best = tmp;
				bestv = j;
			}
		}
		cout << bestv+1 << endl;
		las[bestv] = i+1;
	}
	return 0;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
int main()
{
    string a;
    int b = 0;
    cin >> a;
    for (int i = 0; i < a.length(); i++)
    {
        if(a[i] == '1')
        {
            b++;
        }
    }
    cout << b << endl;
}


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

int main()
{
	std::multimap<string, int> m;
	int N = 0, L = 0;
	cin >> N >> L;
	string s;
	for(int i = 0; i < N; i++){
		cin >> s;
		m.insert(make_pair(s, i));
	}
	for(multimap<string, int>::iterator i = m.begin(); i != m.end(); i++){
		cout << i->first;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(a:i64 b:i64));
  //41桁くらい
  let mut arr = Vec::new();
  arr.resize(41, 0);
  for i in 0..arr.len() {
    arr[i] = xn(b, (i + 1) as u32) - xn(a - 1, (i + 1) as u32);
  }

  let mut p = 1;
  let mut res = 0;
  for &x in &arr {
    res += p * (x % 2);
    p *= 2;
  }
  res.to_string()
}

fn xn(x: i64, n: u32) -> i64 {
  let p = 2i64.pow(n);
  (x + 1) / p * (p / 2) + std::cmp::max(0, (x + 1) % p - p / 2)
}

#[test]
fn xn_test() {
  assert_eq!(xn(1, 1), 1);
  assert_eq!(xn(0, 1), 0);
  assert_eq!(xn(6, 3), 3);
  assert_eq!(xn(4, 2), 2);
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 4\n" => "5\n",
    test2: "123 456\n" => "435\n",
    test3: "123456789012 123456789012\n" => "123456789012\n",
}


Measured memory_bytes: 4352
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
int n;
vector<int> v;
vector<string> ansv;
void dfs(int x=0,int now=(1<<n)-1){
	if(x==n){
		string ans;
		ans.resize(n);
		for(int i=0;i<v.size();i++){
			int y=v[i];
			for(int j=0;j<n;j++)if(y&1<<j)ans[j]='a'+i;
		}
		ansv.pb(ans);
		return;
	}
	if(!(now&1<<x)){dfs(x+1,now);return;}
	for(int i=now^1<<x;;i=i-1&(now^1<<x)){
		v.pb(i|1<<x);
		dfs(x+1,now^i^1<<x);
		v.ppb();
		if(!i)break;
	}
}
int main(){
	cin>>n;
	dfs();
	sort(ansv.begin(),ansv.end());
//	cout<<ansv.size()<<"\n";return 0;
	string ans_final;
	for(int i=0;i<ansv.size();i++)ans_final+=ansv[i],i+1<ansv.size()&&(ans_final+='\n',0);
	puts(ans_final.c_str());
	return 0;
}

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

int main(){
  int i;
  string S;
  vector<string> weather = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  
  cin >> S;
  
  for(i = 0; i < 3; i++){
    if(S == weather[i]){
      break;
    }
  }
  
  cout << weather[i+1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;

int main(){
  ll n;
  cin >> n;
  vector <ll> a(n);
  
  REP(i,n){
      cin >> a[i];
      a[i] -= i+1;   
  }
    
  sort(a.begin(),a.end());
  ll f = -1e10,t = 1e10;
  ll sum1, sum2;
  while(1){
      ll x = (f+t)/2;
      ll y = x+1;
      sum1 = 0;
      sum2 = 0;
      REP(i,n){
          sum1 += abs(a[i]-x);
          sum2 += abs(a[i]-y);
      }
      if(sum1 < sum2){
          t = y;
      }
      else if(sum1 > sum2){
          f = x;
      }
      else{
		  /*
          int ss = 0;
          REP(i,n){
              ss += abs(a[i]-x);
          }
		  */
          cout << sum1 << endl;
          return 0;
      }
      if(abs(f - t) <= 5){
          break;
      }
  }
  
  ll sum = 1e18;
  for(ll i = f-15; i <= t+15;i++){
      ll ssum1 = 0;
      REP(j,n){
          ssum1 += abs(a[j]-i);
      }
      sum = min(sum,ssum1);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1792
s=list(input())
K=int(input())
i=0
while i<len(s):
    if i==len(s)-1:
        s[i]=chr(97+(ord(s[i])-97+K)%26)
        break
    if K<abs(123-ord(s[i]))%26:
        i+=1
    elif K>=abs(123-ord(s[i]))%26:
        sub=abs(123-ord(s[i]))%26
        s[i]="a"
        K-=sub
        i+=1
print("".join(s))

Measured memory_bytes: 4156
#include <iostream>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

int main() {
  double A;
  double B;
  double H;
  double M;
  double k;
  double t;
  double l;
  double p = 3.14159265358979323846264338;
  cin >> A;
  cin >> B;
  cin >> H;
  cin >> M;
  H = H + M / 60;
  k = ( 30.000000000000000 * H - 6.0000000000000000 * M ) * p / 180.00000000000000;
  t = A * A + B * B - 2 * A * B * cos(k);
  
  double d = pow ( t , 0.500000000000000000);
  cout << fixed << setprecision(17) <<  d << endl;
 
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//input



//processing
int ans = 1000000;



//dpTable
//int dp[100050];
int main(){
    int N,K;
    cin >> N >> K;
    for (int bit = 0; bit < (1 << N); bit++) {
        int cnt = 1;
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                cnt += K;
            }
            else {
                cnt *= 2;
            }
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.io.*;
  
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
             
            int num;
			int cnt = n;
            int i, j;
            for( i=0; i<n; i++ ) {
                num = Integer.parseInt( kb.readLine() );
				if( 2 == num ) { continue; }
				if( 0 == num%2 ) {
					cnt--;
					continue;
				}
				int last = (int)Math.sqrt( (double)num );
                for( j=3; j<=last; j+=2 ) {
                    if( 0 == num%j ) {
                        cnt--;
						break;
                    }
                }
            }
             
            System.out.println( cnt  );
              
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 22792
n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

a = [x-1 for x in a]

ans = 0

prev = None
for i in a:
    ans += b[i]
    if prev is not None and prev == i - 1:
        ans += c[i - 1]
    prev = i
print(ans)


Measured memory_bytes: 38384