akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;
const int MOD = 1e9 + 7;

int n;
vector <int> v[MAXN];
pll dp[MAXN]; //dp[i].fi je brojn načina da bude bijelo, a dp[i].fi je broj da bude crno

void dfs(int par, int cvor){
    dp[cvor].fi = dp[cvor].se = 1;
    for (int i = 0; i < v[cvor].size(); i++){
        if (v[cvor][i] == par) continue;
        dfs(cvor, v[cvor][i]);
        dp[cvor].fi = (dp[cvor].fi%MOD * (dp[v[cvor][i]].fi%MOD + dp[v[cvor][i]].se%MOD)%MOD)%MOD;
        dp[cvor].se = (dp[cvor].se%MOD * dp[v[cvor][i]].fi%MOD)%MOD;
    }
}

int main(){

    cin >> n;
    for (int i = 0; i < n-1; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs(-1, 0);

    cout << (dp[0].fi%MOD + dp[0].se%MOD)%MOD;

    return 0;

}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int d, t, s;
	cin >> d >> t >> s;
	cout << (d <= s * t ? "Yes" : "No");
}


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

int main() {
  int N;
  cin>>N;
  int A[N+1];
  int B[N];
  for(int i=0;i<N+1;i++) cin>>A[i];
  for(int i=0;i<N;i++) cin>>B[i];
  long ans=0;
  for(int i=0;i<N;i++){
    if(A[i]+A[i+1]<=B[i]){
      ans+=(A[i]+A[i+1]);
      A[i+1]=0;
    }
    else if(A[i]<B[i]){
      ans+=B[i];
      A[i+1]-=(B[i]-A[i]);
    }
    else ans+=B[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input! {
        extension: u32,
        need: u32,
    }
    println!("{}", solve(extension, need));
}

fn solve(extension: u32, need: u32) -> u32{
    let mut output = 0;
    let mut current_plug = 1;
    while current_plug < need {
        current_plug += extension - 1;
        output += 1;
    }
    output
}

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

int main() {
  int64_t A, Bl, Br;
  char dot;
  cin >> A;
  cin >> Bl >> dot >> Br;
  int64_t result;
  result = A * (Bl * 100 + Br);
  result /= 100;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
using namespace std;

int n;

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

  int k;
  string s;
  scan(n);
  scan(k);
  scan(s);
//  vint s(n);
  REP(i, n){
    if(i==k-1){
      if(s[i]=='A') s[i]='a';
      else if(s[i]=='B') s[i]='b';
      else s[i]='c';
    }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
li=list(map(int,input().split()))


def f(n):
    return n/2 if n%2==0 else 3*n+1
a=li[0]
list=[a]
n=2

while True:
    if not f(list[-1]) in list:
        list.append(f(list[-1]))
        n+=1
    else:
        print(n)
        break

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a == 1 && b == 1 && c == 0)||(a == 0 && b == 0 && c == 1))
    cout << "Open" << endl;
  else
    cout << "Close" << endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> alp(26);
    rep (i, s.size()) alp[s[i] - 'a']++;
    ll res = 1;
    rep (i, 26) res = (res * (alp[i] + 1)) % MOD;
    cout << res % MOD - 1 << endl;
    
    return 0;
}



Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF (1e9)
#define in cin >>
#define LINF (1e18)
#define out cout <<
#define ln  << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define B out "BreakPoint\n";
#define read(_num) scanf("%d",&_num)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_num1,_num2) scanf("%d %d",&_num1,&_num2)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_num1,_num2,_num3) scanf("%d %d %d",&_num1,&_num2,&_num3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
_tp<_tyn T>void print(T _x){for(auto _it=_x.begin();_it!=_x.end();_it++)cout<<*_it<<" ";cout ln;}
void print(int _x){printf("%d ",_x);}
void print(ll _x){printf("%lld ",_x);}
#define MAXN 10010

int h , w , n;
int a[MAXN];
int col[105][105];

int main(){
	//fin( "D.txt" );
	
	read3( h , w , n );
	for( int i = 1 ; i <= n ; i++ )
		read( a[i] );
	
	int xpos = 1 , ypos = 1 , nowc = 1 , nowcleft = a[1];
	while( xpos <= w  &&  ypos <= h ){
		col[ypos][xpos] = nowc;
		nowcleft--;
		if( !nowcleft ){
			nowc++;
			nowcleft = a[nowc];
		}
		if( xpos % 2 == 1 ){
			if( ypos != h ) ypos++;
			else xpos++;
		}else{
			if( ypos != 1 ) ypos--;
			else xpos++;
		}
	}
	
	for( int i = 1 ; i <= h ; i++ ){
		for( int j = 1 ; j <= w ; j++ )
			printf("%d ",col[i][j]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
tmp = 0
ans = 10 ** 10
Asum = sum(A)
for i in range(N - 1):
    tmp += A[i]
    a = abs((Asum - tmp) - tmp)
    if ans > a:
        ans = a
print(ans)


Measured memory_bytes: 24824
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,ans=0,sum=0, Max=-1, Min=3e9+1;
  string s,t;
  cin >> n >> m >> k;
  VL a(n),b(m),aa(n+1),bb(m+1);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  aa[0]=0; bb[0]=0;
  rep(i,n) aa[i+1] = aa[i]+a[i];
  rep(i,m) bb[i+1] = bb[i]+b[i];

  ll j=m;
  rep(i,n+1){
    if(aa[i] > k)
      break;
    while(bb[j] > k - aa[i]){
      j--;
    }
    ans = max(ans, i+j);
  }  
  pri(ans);
  return 0;
}

Measured memory_bytes: 9596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int x;
  cin >> x;
  if (x == 1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		String s = ""; 
		while(true) {
		    int sum = 0;
			s = sc.next();
			if(s.equals("0"))break; 
			for(int i = 0; i < s.length(); i++) {
				if (i == (s.length() - 1)) {
					n = Integer.parseInt(s.substring(i));
				} else {
					n = Integer.parseInt(s.substring(i, i + 1));
				}
				sum += n;
			}
			System.out.println(sum);
		}
		
		sc.close();
	}
}


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

int main() {
	int vacation, assignment, taken = 0, days;
	cin >> vacation >> assignment;
	for(int i=0; i<assignment; i++){
	    cin >> days;
	    taken += days;
	}
	if(taken > vacation) cout << "-1";
	else cout << vacation - taken;
	return 0;
}


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;

void solve(){
    long long a,b;
    cin>>a>>b;
    if(a==1&&b==1)
       cout<<1;
    
    else if(a==1||b==1)
       cout<<max(0LL,((a*b)-2));
    else 
       cout<<max(0LL,((a-2)*(b-2)));
}
int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 3e18;
const ll linf = 3e18;
const double eps = 1e-9;

int N, M, K;
int A[20005];
int memo[20005];

int rec(int now)
{
    if (~memo[now]) return memo[now];

    int res = inf;
    int mi = inf, ma = -inf;
    
    for (int i = 0, to = min(N - now, M); i < to; ++i) {
        mi = min(mi, A[now + i]);
        ma = max(ma, A[now + i]);

        res = min(res, K + (ma - mi) * (i + 1) + rec(now + i + 1));
    }

    if (res == inf) res = 0;

    return memo[now] = res;
}

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    omajinai;
    cin >> N >> M >> K;

    rep(i, N) {
        cin >> A[i];
    }

    memset(memo, -1, sizeof (memo));

    cout << rec(0) << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int x = A/D, y = C/B;
  if(A%D==0) y++;
  if(C%B==0) x++;
  if(x>=y) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
using namespace std;
map <int,int> mp;
int main(){
	int n;
	scanf("%d",&n);
	int ans=0;
	mp[n]=1;
	while(1){
		if(n%2==1){
			n=3*n+1;
		}else{
			n/=2;
		}
		ans++;
		if(mp[n]!=0){
			break;
		}else{
			mp[n]=1;
		}
	}
	printf("%d",ans+1);
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> d(N);
  int i = 0;
  int r = 1;
  for(; i < N; i++) cin >> d[i];
  sort(d.begin(), d.end());
  for(i = 1; i < N; i++) if(d[i] != d[i - 1]) r++;
  cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N, K;
  cin >> N >> K;
  vll P(N);
  rep(i, N) {
    cin >> P[i];
  }
  SORT(P);
  ll ans = 0;
  rep(i, K) {
    ans += P[i];
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] data = new int[N];
        for (int i = 0; i < N; i++) {
            data[i] = sc.nextInt();
        }

        int answer = 0;
        for (int i = 0; i < N - 1; i++) {
            if (data[i] == data[i + 1]) {
                answer++;
                i++;
            }
        }
        
        System.out.println(answer);
    }
}


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

using namespace std;
typedef long long ll;
const ll inf = 1LL<<60;
ll H,W;
vector<vector<char>> S;
vector<vector<ll>> ct;

void bfs(){
    queue<pair<ll,ll>> Q;
    Q.push(make_pair(0,0));

    while(!Q.empty()){
        auto tmp = Q.front();Q.pop();
        ll x = tmp.first, y = tmp.second;

        ll dx[4]={1,0,-1,0};
        ll dy[4]={0,1,0,-1};
        for(int j=0;j<4;j++){
            ll tx=x+dx[j],ty=y+dy[j];
            if(tx>=W || tx<0 || ty>=H || ty<0) continue;
            else {
                if(S[ty][tx]=='.' && ct[ty][tx]>ct[y][x]+1){
                    ct[ty][tx]=ct[y][x]+1;
                    Q.push(make_pair(tx,ty));
                }
            }
        }
    }
}

int main() {
    cin >> H >> W;
    ll blk=0;
    S.assign(H,vector<char>(W));
    ct.assign(H,vector<ll>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> S[i][j];
            if(S[i][j]=='#') blk++;
        }
    }
    for(int i=0;i<H;i++){
        fill(ct[i].begin(),ct[i].end(),inf);
    }
    ct[0][0]=0;
    bfs();
    if(ct[H-1][W-1]==inf) {
        cout << -1 << endl;
        return 0;
    }
    
    cout << H*W - 1 - blk - ct[H-1][W-1] << endl;
}

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

using namespace std;

int main(){

    string s;
    cin >> s;

    int c = -1;
    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'C'){
            c = i;
            break;
        }
    }
    if (c >= 0){
        bool flag = false;
        for (int i = c; i < s.length(); i++){
            if (s[i] == 'F'){
                flag = true;
                break;
            }
        }
        if (flag == true){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main() {
	int n,tmp=0;
	cin >> n;
	vector<int64_t>h(n);
	for (int i=0;i<n;i++) cin >> h.at(i);
	bool endf=false;
  if (n==1) endf=false;
  else{
  	tmp=0;
		for(int i=n-1;i>0;i--){
			if(h.at(i)-tmp<h.at(i-1)-1){
				endf=true;
				break;
			}
			else if(h.at(i)-tmp==h.at(i-1)-1){
				tmp=1;
			}
			else{
				tmp=0;
			}
		}
	}
	if (endf==true) cout << "No" << endl;
	else cout << "Yes" << endl;
	
}


Measured memory_bytes: 1024
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

# t = int(stdin.readline())
# for _ in range(t):
# n, m = map(int, stdin.readline().split())
# nums = list(map(int, stdin.readline().split()))
n = int(input())
if n%10 in [2, 4, 5, 7, 9]:
    print('hon')
elif n%10 in [0, 1, 6, 8]:
    print('pon')
else:
    print('bon')


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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final int d = stdin.nextInt();

	int[] dx = {0, 1, 0, -1};
	int[] dy = {-1, 0, 1, 0};
	final int UP = 0;
	final int RIGHT = 1;
	final int DOWN = 2;
	final int LEFT = 3;
	
	for ( int t = 0; t < d; t++ ) {

	    final int n = stdin.nextInt();
	    char[][] map = new char[n][n];
	    for ( char[] array : map ) {
		Arrays.fill( array, ' ' );
	    }

	    int x = 0;
	    int y = n;
	    int dir = UP;

	    int[] move = getMoveDistance( n );		

	    for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < move[i]; j++ ) {
		    x += dx[dir];
		    y += dy[dir];
		    map[y][x] = '#';
		}
		dir = ( dir + 1 ) % 4; 
	    }
	    for ( char[] array : map ) {
		System.out.println( new String( array ) );
	    }
	    if ( t < d - 1 ) {
		System.out.println();
	    }
	}	
    }

    static int[] getMoveDistance( final int n ) {

	if ( n == 1 ) {
	    int[] ans = {1};
	    return ans; 
	} else {
	    int[] ans = new int[n];
	    ans[0] = n;
	    int rest = n;
	    rest -= 1;
	    for ( int index = 1; index < n; ) {
		ans[index] = rest;
		index++;
		if ( index >= n ) {
		    break;
		}
		ans[index] = rest;
		index++;
		rest -= 2;
	    }
	    return ans;
	}
    }    
}

Measured memory_bytes: 20816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
//#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
//#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
//#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
//template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
//template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
//
//using Graph = vector<vector<int>>;
//using P = pair<int, int>;
//using Tuple = tuple<int, int, int>;

ll dp[200005][2][3];


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

    rep(i, n+1) rep(j, 2) rep(k, 3) dp[i][j][k] = -1LL<<60;
    dp[0][1][0]=0;

    rep(i, n) rep(j, 2) rep(k,3) {
        if(k+j < 3) dp[i+1][1][k+j] = max(dp[i+1][1][k+j], dp[i][j][k]);
        if(j==1) dp[i+1][0][k] = max(dp[i+1][0][k], dp[i][j][k]+a[i]);
    }

    if(n%2==0) cout << max(dp[n][1][0], dp[n][0][1]) << endl;
    else cout << max(dp[n][0][2], dp[n][1][1]) << endl;


    return 0;
}


Measured memory_bytes: 14344
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

bool check(int i,string str){

	string ans;
	if(i%15==0) ans = "FizzBuzz";
	else if(i%3==0) ans = "Fizz";
	else if(i%5==0) ans = "Buzz";
	else{
		char buf[128];
		sprintf(buf,"%d",i);
		ans = buf;
	}

	return (ans == str);
}

int main(){
	int m,n;
	while(~scanf("%d %d",&m,&n)){
		if(m==n && n==0) break;
		list<int> player;
		for(int i=1;i<=m;i++) player.push_back(i);

		int alive = m;
		for(int i=0,j=0;i<n;i++){		
			string str;
			cin >> str;
			if(alive>1 && !check(i+1,str)){
				list<int>::iterator it = player.begin();
				advance(it,j);
				player.erase(it);
				alive--;
			}
			else j++;

			j %= alive;
		}

		for(list<int>::iterator it = player.begin(); it != player.end(); it++){
			printf("%s%d",it == player.begin() ? "" : " ",*it);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3180
#include<stdio.h>
int GCD (int a, int b) {
	return b ? GCD (b, a % b) : a;
}
int LCM (int a, int b) {
	return a / GCD (a, b) * b;
}
int main () {
	int a, b;
	while (~scanf("%d%d", &a, &b)) {
		printf("%d %d\n", GCD(a, b), LCM (a, b));
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<ll,ll> mp;
    ll ans = 1;
    REP(i,N){
        int num;
        cin >> num;
        if(num == 0) ans *= (3 - mp[num]);
        else{
            ans *= (mp[num-1] - mp[num]);
            //mp[num-1]--;
        }
        mp[num]++;
        ans %= MOD;
    }

    ans %= MOD;
    
    cout << ans << endl;
}


Measured memory_bytes: 6528
#pragma GCC optimize("03")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e2 + 1;

ll n, l;
string s, a[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n >> l;
	for (ll i = 1; i <= n; ++i) cin >> a[i];
	
	sort(a+1, a+1 + n);
	for (string& s: a) cout << s;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

struct UF {
  vector<int> par; // parent
  vector<int> sizes;
  UF(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; ++i) {
      par[i] = i;
    }
  }
  int root(int x) {
    if (x == par[x]) {
      return x;
    }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (sizes[x] < sizes[y]) {
      swap(x, y);
    }
    par[y] = x;
    sizes[x] += sizes[y];
    sizes[y] = 0;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};

int n;
vvi g;
vi par;

void set_par(int u, int prev) {
  for (int v : g[u]) {
    if (v == prev) { continue; }
    par[v] = u;
    set_par(v, u);
  }
}

int main() {
  scanf("%d", &n);
  g.resize(n);
  vvi edges(n-1, vi(2));
  rep (i, n-1) {
    int a, b;
    scanf("%d %d", &a, &b);
    a -= 1; b -= 1;
    g[a].push_back(b);
    g[b].push_back(a);
    edges[i][0] = min(a, b);
    edges[i][1] = max(a, b);
  }
  par.assign(n, -1);
  set_par(n-1, -1);

  vi path;
  for (int u = 0; ; u = par[u]) {
    path.push_back(u);
    if (u == n-1) {
      break;
    }
  }

  int m = path.size();
  int a, b;
  a = path[(m-1)/2];
  b = path[(m+1)/2];
  if (a > b) {
    swap(a, b);
  }
  UF uf(n);
  for (vi p : edges) {
    if (p[0] == a && p[1] == b) { continue; }
    uf.unite(p[0], p[1]);
  }

  if (uf.size(0) > uf.size(n-1)) {
    printf("Fennec\n");
  } else {
    printf("Snuke\n");
  }

  return 0;
}


Measured memory_bytes: 17532
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int a[5];
  while(1){
    cin >> a[0];
    if(a[0]==0)break;
    int b[3]={0};
    b[a[0]-1]++;
    for(int i=1;i<5;i++){
      cin >> a[i];
      b[a[i]-1]++;
    }
    int w;
    if((b[0]!=0&&b[1]!=0&&b[2]!=0)||b[0]==5||b[1]==5||b[2]==5){
      for(int i=0;i<5;i++) cout << 3 << endl;
    }else{
      if(b[0]==0){
	w=1;
      }else if(b[1]==0){
	w=2;
      }else{
	w=0;
      }
      for(int i=0;i<5;i++){
	if(a[i]==w+1){
	  cout << 1 << endl;
	}else {
	  cout << 2 << endl;
	}
      }
    }
  }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int dp[10000030][2] = {};
int main() {
	long long int x;
	cin >> x;
	for (long long int i = 0; i <= x; i++) {
		dp[i][0] = 1;
	}
	for (long long int i = 2; i <=x; i++) {
		//cout << i << endl;
		if (dp[i][0] == 1) {
			long long int  a = i;
			while (a <= x) {
				//cout << a << endl;
				for (long long int j = a; j <= x; j = j + a) {
					//cout << j << endl;
					dp[j][1]++;
				}
				//cout << a << endl;
				a = a * i;
			}
			for (long long int j = i; j <= x; j = j + i) {
				dp[j][0] = dp[j][0] * (dp[j][1] + 1);
				dp[j][1] = 0;
			}
		}
		//cout << "ok" << endl;
	}
	long long int ans = 0;
	for (int i = 1; i <= x; i++) {
		ans = ans + i * dp[i][0];
		//cout << i * dp[i][0] << endl;
	}
	cout << ans;
}

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

int main(){
    string s;
    cin >> s;

    string ans;

    for(long long i = 0; i < s.size(); i++){
        if(i % 2 == 0) ans.push_back(s[i]);
    }

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

Measured memory_bytes: 3700
N,M = map(int,input().split())
a = []
if M >= 1:
    for i in range(M):
        a.append(int(input()))

def fibo(n):
    a, b = 1, 1
    if (n == 0) or (n == 1) or (n == 2):
        return 1
    else:
        for _ in range(n-2):
            a, b = b, a + b
        return b

aa = [] #aの差を取ったもののリスト
if M >= 2:
    for k in range(M-1):
        aa.append(a[k+1] - a[k] - 1)
#print(aa)
#aa.append(N - a(M))

    if 0 in aa:
        ans = 0

    else:
        ans = 1
        ans_list = []
        for i in range(M-1):
            ans_list.append(fibo(aa[i]))

        ans_list.append(fibo(a[0]))
        ans_list.append(fibo(N - a[M-1]))
    #print(ans_list)
    
        for i in range (len(ans_list)):
            ans = (ans * ans_list[i]) % (10**9 + 7)

elif M == 1:
    ans_list = []
    ans_list.append(fibo(a[0]))
    ans_list.append(fibo(N - a[0]))
    ans = (ans_list[0] * ans_list[1]) % (10**9 + 7)

elif M == 0:
    ans = fibo(N+1) % (10**9 + 7)

print(ans)


Measured memory_bytes: 7856
#Pはiが素数かどうかを表すlist
#素数でないと判明したらFalseに書き換える
P = [True]*100001
for i in range(2,100001):#2から始める
    if P[i]:
        for j in range(i+i,100000,i): #stepはi
            P[j] = False

#2017に似た数の個数をあらかじめ求める
#C[i]はi以下の2017に似た数の個数
C = [0 for _ in range(100002)]
#まずC[i]にiと(i+1)/2が2017likeであれば1を格納
for i in range(3,100000,2):
    if P[i] and P[(i+1)//2]:
        C[i] += 1
#C[i]はi<以下>の2017likeな数の個数なので，
#下から個数を足していく（累積和という）
for i in range(3,100000):
    C[i+1] += C[i]
Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(C[r]-C[l-1])


Measured memory_bytes: 7192
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  a <- replicateM n readLn
  let
    solve m [] = m
    solve m [x] = m + x `div` 2
    solve m (x:y:xs)
      | y == 0 = solve (m+x`div`2) xs
      | x < y  = solve (m+x) ((y-x):xs)
      | odd x  = solve (m+1+x`div`2) ((y-1):xs)
      | otherwise = solve (m+x`div`2) (y:xs)
  print $ solve 0 a


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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

const ll mod = 1000000007;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void solve() {
    /*ll sum = 0;
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for(ll i = 1; i<=n; i++) {
        for(ll j = 1; j<=n; j++) {
            for(ll k = 1; k<=n; k++) {
                ll g = __gcd(i, __gcd(j, k));
                mp[g] ++;
                sum += g;
            }
        }
    }
    for(auto it: mp) {
        cout << it.first << ' ' << it.second << '\n';
    }
    cout << sum ;
    */
    ll n, k;
    cin >> n >> k;
    ll ans[k+1] = {};
    ans[k] = 1;
    for(ll i = k-1; i>=1; i--) {
        if(k/i > 0) {
            ll times = k/i;
            ll num = power(times, n);
            for(ll j = 2*i; j<=k; j+=i) {
                num = (num%mod - ans[j]%mod + mod)%mod;

            }
            ans[i] = num;
        }
        else {
            ans[i] = 1;
        }
    }
    ll out = 0;
    for(ll i = 1; i<=k; i++) {
        //debug2(i, ans[i])
        out = (out%mod + (ans[i]%mod * i%mod)%mod)%mod;
    }
    cout << out << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int W = in.nextInt();
            int costValueMatrix[][] = CPUtils.readIntMatrix(N, 2, in);
            long matrix[][] = new long[N + 1][W + 1];
            for (int i = 0; i <= N; i++)
            {
                Arrays.fill(matrix[i], 0);
            }
            for (int item = 1; item <= N; item++)
            {
                for (int w = 1; w <= W; w++)
                {
                    if (costValueMatrix[item - 1][0] <= w)
                    {
                        matrix[item][w] = Math.max(
                                matrix[item - 1][w],
                                costValueMatrix[item - 1][1] + matrix[item - 1][w - costValueMatrix[item - 1][0]]
                        );
                    } else
                    {
                        matrix[item][w] = matrix[item - 1][w];
                    }
                }
            }
            out.print(matrix[N][W]);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

        public static int[][] readIntMatrix(int rows, int columns, Scanner in)
        {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                matrix[i] = CPUtils.readIntArray(columns, in);
            }
            return matrix;
        }

    }
}



Measured memory_bytes: 127060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  c = a/500;
  c = a-500*c;
  if (c<=b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll a,b;
ll f(ll t){
	if(t%4==0){
		return t;
	}else if(t%4==1){
		return 1;
	}else if(t%4==2){
		return t+1;
	}else if(t%4==3){
		return 0;
	}
}
int main(){
	cin>>a>>b;
	if(a==0)cout<<f(b)<<endl;
	else cout<<(f(a-1)^f(b))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N, K;   cin >> N >> K;
    int x = 1;
    double ans = 0;

    for (; x <= min(K-1,N); x++) {
        int y = x;
        int cnt = 0;
        while (y < K) {
            y *= 2;
            cnt++;
        }
        
        ans += 1.0/(double)N * pow(0.5, cnt);
    }

    for (; x <= N; x++)
        ans += 1.0/(double)N;

    cout << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split();
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            Console.WriteLine("{0} {1}", a * b, (a + b) * 2);
        }
    }
}

Measured memory_bytes: 9052
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
string tra(string x) {
	int len = x.length();
	int ma = 0;
	for (int i = 1; i < len; i++) {
		string u = x.substr(0, i);
		string v = x.substr(i, len - i);
		int sum = stoi(u)*stoi(v);
		ma = max(ma, sum);
	}
	return to_string(ma);
}
int main() {
	int q; cin >> q;
	string n; int cnt;
	for (int i = 0; i < q; i++) {
		cin >> n;
		for (cnt = 0; cnt < 100000; cnt++) {
			if (n.length()==1)break;
			n = tra(n);
		}
		if (cnt == 100000)cout << -1 << endl;
		else cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  int n, m, x, c[15], a[15][15];
  cin >> n >> m >> x;
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  }
  int ans = INF;
  for (int bit = 0; bit < (1 << n); ++bit) {
    int aSum[15] = {0}, cSum = 0;
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        cSum += c[i];
        for (int j = 0; j < m; ++j) {
          aSum[j] += a[i][j];
        }
      }
    }
    bool aJudge = true;
    for (int i = 0; i < m; ++i) {
      if (aSum[i] < x) {
        aJudge = false;
        break;
      }
    }
    if (aJudge) ans = min(ans, cSum);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <assert.h>
using namespace std;
#define int long long

signed main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (x * 2 >= a * a * b) {
		cout << fixed << setprecision(15) << (180 / acos(-1)) * atan2(2 * (b - x / ((double)a * a)), a) << endl;
	}
	else {
		cout << fixed << setprecision(15) << (180 / acos(-1)) * atan2(b, 2 * x / ((double)a * b)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    vector<int> s(n);

    for (int i = 0; i < n; i++)
        scanf("%d", &s[i]);

    sort(s.begin(), s.end());

    int c = 0;
    for (int i = 0; i < n; i++)
    {
        if (x < s[i])
            break;

        x -= s[i];
        c++;
    }

    if (c == n && x != 0)
        c--;

    printf("%d\n", c);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long ll;
int main() {
    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    q=4*q;
    h=2*h;
    q=min(q,h);
    q=min(q,s);
    if(2*q<=d){
        cout<<n*q<<"\n";
    }
    else{
        if(n%2==0){cout<<(n/2)*d<<"\n";}
        else{
            cout<<((n-1)/2)*d+q<<"\n";
        }
    }
	return 0;
}


Measured memory_bytes: 256
import sys
for i in sys.stdin:
	m, n = map(int, i.split())
	t1, t2 = m, n
	while True:
		if m % n == 0:
			break
		m, n = n, m % n
	a = n
	b = (t1/ a) * t2
	print("{} {}".format(a, b))

Measured memory_bytes: 4204
#include <iostream>
#include <math.h>
using namespace std;

int main () {

    int a,b;
    cin>>a>>b;
    if ((a%2==0 && b%2==0) || (a%2==1 && b%2==1)){
        cout << min(a,b)+(max(a,b)-min(a,b))/2 << endl;
    }
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])

ab.sort(key=lambda x: x[1])
time = 0
for i in range(n):
    time += ab[i][0]
    if time > ab[i][1]:
        print("No")
        break
else:
    print("Yes")

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

int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int ans;
    ans = (H2*60 + M2) - (H1*60 + M1) -K;
    cout << ans << endl;
}

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

#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long MAX = 1LL << 60;
// n 番目 (0-based)に到達するのに必要な最小のコスト
long long dp[100010];

int main() {
    int N;
    cin >> N;
    vector<int> hs(N);
    REP(i, N) {
        cin >> hs[i];
    }

    REP(i, N) {
        dp[i] = MAX;
    }
    dp[0] = 0;

    REP(i, N) {
        if (i - 1 >= 0) {
            chmin(dp[i], dp[i - 1] + abs(hs[i - 1] - hs[i]));
        }
        if (i - 2 >= 0) {
            chmin(dp[i], dp[i - 2] + abs(hs[i - 2] - hs[i]));
        }
    }

    printf("%lld\n", dp[N - 1]);

    return 0;
}


/*
 * Local Variables:
 * compile-command: "CXXFLAGS='-std=c++14' make main"
 * End:
 */

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
  	vector<int> v;
	if(n==0){
		cout << 0 << endl;
		return 0;
	}
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	if(n==-1){
		cout << 11 << endl;
		return 0;
	}
	while(n/(-2)!=0){
		//cout << n << endl;
		if(n%(-2)==0) v.push_back(0);
		else v.push_back(1);
		if(n<0){
			n *= -1;
			n += n%2;
			n /= 2;
		}else{
			n /= (-2);
		}
		if(n==1){
			v.push_back(1);
			break;
		}
		if(n==-1){
			v.push_back(1);
			v.push_back(1);
			break;
		}
	}

	reverse(v.begin(),v.end());
	for(auto u : v){
		cout << u;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256