akhauriyash/Code-Regression huggingface dataset:
R,G,B,N=map(int,input().split())
A=[0]*(N+1)
A[0]=1
for i in range(N+1-R):
    A[i+R]=A[i]
for k in range(N+1-G):
    A[k+G]+=A[k]
for h in range(N+1-B):
    A[h+B]+=A[h]
print(A[N])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int A[5];
    rep(i,5){
      cin >> A[i];
    }
    int k;
    cin >> k;
    cout << (A[4]-A[0] <= k ? "Yay!":":(") << endl;
}


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

using ll = long long;
using namespace std;



int main() {
    int a, b, ab, x, y;
    cin >> a >> b >> ab >> x >> y;
    int t = max(x, y), u = min(x, y);
    vector<int> s(3);
    s[0] = x * a + y * b;
    s[1] = (x-u) * a + (y-u) * b + 2*u * ab;
    s[2] = 2 * t * ab;
    sort(s.begin(), s.end());
    cout << s[0] << "\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll cc = 0;
    while(b <= a){
        b *= 2;
        cc++;
    }
    while(c <= b){
        c *= 2;
        cc++;
    }
    if(cc <= k){
        prtl("Yes");
    }else{
        prtl("No");
    }
}


Measured memory_bytes: 3644
def divisors(n):
    l = []
    for i in range(1, n+1):
        if n % i == 0:
            l.append(i)
    return l


n = int(input())
cnt = 0
for n in range(1, n+1, 2):
    d = divisors(n)
    if len(d) == 8:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#pragma warning(disable: 4996)
#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)

using namespace std;

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(x * a, y * a); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }

	bool operator < (const Point& p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point& p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

///Program 16.3 表示线段的结构体
struct Segment {
	Point p1, p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};


///内积
double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}
///外积
double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) {//printf("COUNTER_CLOCKWISE\n");
		return 1;
	}///p2位于p0-->p1的逆时针方向
	if (cross(a, b) < -EPS) {//printf("CLOCKWISE\n");
		return -1;
	}///p2位于p0-->p1的顺时针方向
	if (dot(a, b) < -EPS) {//printf("ONLINE_BACK\n");
		return 2;
	}///p2位于线段p0p1后方
	if (a.norm() < b.norm()) { //printf("ONLINE_FRONT\n");
		return -2;
	}///p2位于线段p0p1前方

//  printf("ON_SEGMENT\n");///p2位于线段p0p1的中间
	return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
		ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

double norm(Point p) { return p.x * p.x + p.y * p.y; }
double abs(Point p) { return sqrt(norm(p)); }

Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	//   return s.p1 + (base*r);
	Point ans;
	ans.x = s.p1.x + (base * r).x;
	ans.y = s.p1.y + (base * r).y;
	return ans;
}

pair<Point, Point> getCrossPoints(Circle c, Line l) {
	// assert(intersect(c.c,l));
	Vector pr = project(l, c.c);
	Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
	double base = sqrt(c.r * c.r - norm(pr - c.c));
	return make_pair(pr - e * base, pr + e * base);
}

int main()
{
	Circle c;
	scanf("%lf%lf%lf", &c.c.x, &c.c.y, &c.r);
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		Line l;
		scanf("%lf%lf%lf%lf", &l.p1.x, &l.p1.y, &l.p2.x, &l.p2.y);
		pair<Point, Point> p = getCrossPoints(c, l);
		if((p.first.x<p.second.x)||(p.first.x==p.second.x&&p.first.y<p.second.y))
			printf("%.8f %.8f %.8f %.8f\n", p.first.x, p.first.y, p.second.x, p.second.y);
		else 
			printf("%.8f %.8f %.8f %.8f\n", p.second.x, p.second.y, p.first.x, p.first.y);
		
	}
	return 0;
}


Measured memory_bytes: 3248
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        Int in;
        cin >> in;
        in--;
        a[i] = in;
    }

    vector<bool> seen(n, false);
    Int now = 0, coun = 0, len = 0, ro = 2 * n;
    bool isf = true;
    vector<Int> anser;
    for (Int i = 0; i < ro; i++) {
        if (seen[now]) {
            if (isf) {
                coun = i;
                isf = false;

                seen.assign(n, false);
                anser.push_back(now);
                seen[now] = true;
                now = a[now];
            } else {
                len = i - coun;
                break;
            }
        } else {
            if (!isf) {
                anser.push_back(now);
            }

            seen[now] = true;
            now = a[now];
        }
    }

    if (n <= k) {
        Int ans = (k - coun) % len;
        cout << anser[ans] + 1 << endl;
    } else {
        now = 0;
        for (Int i = k - 1; i >= 0; --i) {
            now = a[now];
        }

        cout << now + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6800
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W = MI()
    sx, sy = MI()
    gx, gy = MI()
    sx-=1
    sy-=1
    gx-=1
    gy-=1
    
    mylist = [input().rstrip() for i in range(H)]
    dist = Init(H, W, float('inf'))
    #dist2 = Init(H, W, float('inf'))
    dq = deque()
    dq2 = deque()
    dq.append((sx, sy))
    move1 = [[1,0],[0,1],[-1,0],[0,-1]]
    move2 = [[i,j] for i in range(-2,3) for j in range(-2,3) if not [i, j ] in move1 and [i, j] != [0, 0]]
    dist[sx][sy] = 0
    while dq:
        while dq:
            x, y = dq.popleft()
            if x == gx and y == gy:
                print(dist[gx][gy])
                sys.exit()


            #コスト1の移動
            for x2, y2 in move2:
                x2 += x
                y2 += y
                if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] == "." and dist[x2][y2] > dist[x][y]+1:
                    dist[x2][y2] = dist[x][y]+1
                    dq2.append((x2,y2))

            #コスト0の移動
            for x2, y2 in move1:
                x2 += x
                y2 += y
                if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] == "." and dist[x2][y2] > dist[x][y]:
                    dist[x2][y2] = dist[x][y]
                    dq.append((x2,y2))


        dq = deque(set(dq2))
        dq2 = deque()
        
    
    if dist[gx][gy] == float('inf'):
        print(-1)
    else:
        print(dist[gx][gy])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 109104
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


ll dp[111][11111]={};
int main(void) {
  ll N;
  cin >> N;
  ll a[111];
  ll i, j;
  
  for(i=0; i<N; i++) cin >> a[i];
  
  dp[0][0]=1;
  for(i=0; i<N; i++) {
    for(j=0; j<10101; j++) {
      chmax(dp[i+1][j]     , dp[i][j]);
      chmax(dp[i+1][j+a[i]], dp[i][j]);
    }
  }
  
  for(i=10101; i>=0; i--) {
    if(dp[N][i] && i%10) {
      pt(i);
      return 0;
    }
  }
  
  pt(0);
}






Measured memory_bytes: 7168
import math
a, b, h, m = map(int,input().split())
 
ha = 360/12*h+0.5*m
ma = 360/60*m
 
s =  abs(ha-ma)
if s >180:
  s=360-s
 
ans = (a**2 + b**2 -2*a*b*math.cos(math.radians(s)))**(1/2)
 
print(ans)

Measured memory_bytes: 9512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int n=s.size();
    cout<<s[0]<<n-2<<s.back()<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, M;
    cin >> N >> M;
    if(N == 1 && M == 1) {
        output(1);
    }
    else if(N == 1 || M == 1){
        ll a = max(N, M);
        output(a - 2);
    }
    else {
        output((N - 2) * (M - 2));
    }
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int e;
	while(cin >> e && e){
		int ans = (1<<23);
		for(int z = 0; z*z*z<=e;z++)
			for(int y=0;y*y <= e-z*z*z;y++)
				ans = min(ans,z+y+e-z*z*z-y*y);
		cout << ans << endl;
	}
}

Measured memory_bytes: 864
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int counts = 0;
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      if (a == b) {
        counts += 1;
        if (counts == 3) {
          break;
        }
      } else {
        counts = 0;
      }
    }
    if (counts == 3) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 36024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    map<int,int> cnt;
    rep(i,n){
        cnt[a[i]]++;
    }
    ll ans=0;
    for(auto v:cnt){
        if(v.first<v.second)ans+=v.second-v.first;
        else if(v.first>v.second)ans+=v.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8136
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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 main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = s.size() - 1; i > 0; i--) {
    if (s[i] != s[i - 1]) {
      ans += 2;
      s.erase(s.begin() + i - 1, s.begin() + i + 1);
      i--;
      while (i > 0 && i <= s.size() - 1) {
        if (s[i] != s[i - 1]) {
          ans += 2;
          s.erase(s.begin() + i - 1, s.begin() + i + 1);
          i--;
        } else {
          break;
        }
      }
    }
  }
  P(ans);
  return 0;

}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdn = new Scanner(System.in);
		int a = 0;
		int b = 0;
		
		a = stdn.nextInt();
		b = stdn.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26324
N, A, B, C, D = map(int, input().split())
S = input()

if C < B:
    if S[A-1:C-1].find("##") == -1 and S[B-1:D-1].find("##") == -1:
        print("Yes")
    else:
        print("No")
elif D > C :
    if S[A-1:D-1].find("##") == -1 :
        print("Yes")
    else:
        print("No")
else:
    if S[A-1:C].find("##") == -1 and S[B-2:D+1].find("...") >= 0:
        print("Yes")
    else:
        print("No")



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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

using Graph = vector<vector<int>>;


vector<bool> seen;
vector<int> cnt;

void dfs(const Graph &G, int v, int x) {
  seen[v] = true;
  cnt[v] += x;

  for(auto next_v : G[v]) {
    if(seen[next_v]) continue;
    dfs(G, next_v, cnt[v]);
  }
}


int main(void)
{
  int n, q;
  cin >> n >> q;
  Graph G(n);
  
  REP(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> p(q);
  vector<int> x(q);
  cnt.assign(n, 0);
  
  REP(i, q) {
    cin >> p[i] >> x[i];
    cnt[p[i]-1] += x[i];
  }  
  seen.assign(n, false);  
  dfs(G, 0, 0);

  REP(i, n) {
    if(i) cout << " ";
    cout << cnt[i];
  }
  cout << endl;
}


Measured memory_bytes: 25088
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  if A[i] >= B[i]:
    ans += B[i]
  elif A[i]+A[i+1] >= B[i]:
    ans += B[i]
    A[i+1] -= B[i] - A[i]
  else:
    ans += A[i]+A[i+1]
    A[i+1] = 0
print(ans)


Measured memory_bytes: 18624
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[100001];
	rep1(i, N) A[getint()] = i + 1;
	int dai[100004], shou[100004];
	shou[0] = 2;
	dai[N + 3] = N + 1;
	rep1(i, N) {
		dai[i + 2] = i + 1;
		shou[i] = i + 1;
	}

	ll kotae = 0;
	rep1(i, N) {
		int a = A[i];
		int l = shou[a - 1];
		int r = dai[a + 1];
		int l2 = shou[l - 2];
		int r2 = dai[r + 2];

		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;

		dai[l] = r;
		shou[r] = l;
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	bool ans = 0;
	cin >> a >> b;
	for(int i=1; i<=3; i++){
		if((a*b*i) % 2 == 1) ans = 1;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int data[150000] = {};
  int size = sizeof(data) / sizeof(int);

  for (int i = 2; i < size; ++i) {
    for (int j = i * 2; j < size; j += i)
      data[j] = 1;
  }

  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    int ans = 0;
    for (int i = 2, cnt = 0; cnt < n; ++i) {
      if (data[i] == 0) {
        ans += i;
        ++cnt;
      }
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 3680
M=998244353
*d=1,*[s=0]*2e5
*e=d
gets
$<.map{s+=a=_1.to_i
s.downto(0){|i|d[i+a]+=d[i]*2%M
e[i+a]+=e[i]%M}}
p (d.sum+~s%2*e[s/2]*3-d[0..s/2].sum*3)%M

Measured memory_bytes: 20648
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] xs = sc.next().toCharArray();
        Character current = null;
        int types = 0;
        for (int i = 0; i < n; i++) {
            char c = xs[i];
            if (current == null) {
                types++;
            }
            else if (c != current) {
                types++;
            }
            current = c;
        }

        System.out.println(types);
    }
}


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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a_s: [i64; n],
    }
    let abs_min = a_s.iter().map(|x| x.abs()).min().unwrap();
    // if contains 0
    if abs_min == 0 {
        let ans = a_s.iter().fold(0, |sum, x| sum + x.abs());
        println!("{}", ans);
        return;
    }

    // all plus
    {
        let mut count = 0;
        for i in 0..n {
            if a_s[i] < 0 {
                count += 1;
            }
        }
        if count % 2 == 0 {
            let ans = a_s.iter().fold(0, |sum, x| sum + x.abs());
            println!("{}", ans);
            return;
        }
    }

    // flip abs_min
    let ans = a_s.iter().fold(0, |sum, x| sum + x.abs()) - 2 * abs_min;
    println!("{}", ans);
}


Measured memory_bytes: 4352
//lunchtime june Increasing and Decreasing
//<<  <  ,
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)
#define MOD 1000000007
#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}


void solve()
{   ll n;
    in n;
    ll a[10010]={0};
    for(ll i=1;i<=200;i++){
        for(ll j=1;j<=200;j++){
            for(ll k=1;k<=200;k++){
                ll check=pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i;
                if(check<10010)
                   a[check]++;
            }
        }
    }
    for(ll i=1;i<=n;i++){
        out a[i]<<en;
    }
}




int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3628
N, X, Y = map(int, input().split())
if X > Y:
    X, Y = Y, X


ans = [0] * N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        d = 0
        if i <= X and j <= X:
            d = j - i
        elif i <=X and j > X and j <= Y:
            d = min(j-i, X-i+1+Y-j)
        elif i <= X and j > Y:
            d = X - i + 1 + j - Y
        elif i > X and i <= Y and j > X and j <= Y:
            d = min(j-i, i-X+1+Y-j)
        elif i > X and i <= Y and j > Y:
            d = min(j-i, i-X+1+j-Y)
        elif i > X and j > Y:
            d = j - i
        ans[d] += 1

for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 48476
#include<iostream>
#include<string>
#include<algorithm>
#include <map>  
#include <string.h>

using namespace std;


int N, M ,sum=0;
int a[50], b[50];
int L[51][51] = {};

struct S {
	int l[51][51] = {};
};

bool dec(struct S s, int n, int ans) {
	bool flag = false;

	for (int i = 1; i <= N; i++) {
		if (n<i && s.l[n][i] == 1 || n>i && s.l[i][n] == 1) {
			if (i == ans)
				return true;
			else {
				if (n > i)
					s.l[i][n] = 0;
				else
					s.l[n][i] = 0;

				if (dec(s, i, ans))
					return true;
			}
		}
	}
	return flag;
}


int main()
{

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		if(a[i] > b[i])
			L[b[i]][a[i]] = 1;
		else
			L[a[i]][b[i]] = 1;
	}



	for (int i = 0; i < M; i++) {
		struct S s;
		memcpy(s.l, L, sizeof(L));

		if (a[i] > b[i])
			s.l[b[i]][a[i]] = 0;
		else
			s.l[a[i]][b[i]] = 0;

		if (!dec(s, a[i], b[i]))
			sum++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(){
  int A,B,C,X;//Xは交換用置き場
  scanf("%d %d %d ",&A,&B,&C);
  X=A;
  A=B;
  B=X;
  X=A;
  A=C;
  C=X;
  printf("%d %d %d",A,B,C);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    string a, b, c; cin >> a >> b >> c;

    int ans = 0;
    rep(i, n){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }
        if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]){
            ans++;
        }
        else{
            ans += 2;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int h;
    cin>>h;
    int a;
    cin>>a;
    if(h>=1&&h<=10000)
    {
        if(a>=1&&a<=10000)
        {
            int i=0;
            while(h>0)
            {
                h=h-a;
                i++;
            }
            cout<<i;

        }



    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint RepeatSquaring(mint N, ll P) {
  if (P == 0) return 1;
  if (P % 2 == 0) {
    mint t = RepeatSquaring(N, P / 2);
    return t * t;
  }
  return RepeatSquaring(N, P - 1) * N;
}

mint COM(ll n, ll k) {
  mint deno = 1;
  mint mole = 1;
  for (ll i = 0; i < k; i++) {
    deno *= n - i;
    mole *= (i + 1);
  }

  mint nCk = deno / mole;
  return nCk;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // 前処理
  // COMinit();
  mint n, a, b;
  cin >> n.x >> a.x >> b.x;

  mint ans = RepeatSquaring(2, n.x);
  ans -= 1;

  ans -= COM(n.x, a.x);
  ans -= COM(n.x, b.x);
  cout << ans.x << endl;
}



Measured memory_bytes: 256
var
  a,b,c,i,ans:longint;
  s:array[1..100000]of longint;
begin
  read(a,b,c);
  for i:=1 to a do
    begin
      read(s[i]);
      if(s[i]<b)or(s[i]>=c)then inc(ans);
    end;
  writeln(ans);
end.

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            var isS = S.Contains('S');
            var isN = S.Contains('N');
            var isE = S.Contains('E');
            var isW = S.Contains('W');
            if (isS == isN && isE == isW)
                WriteLine("Yes");
            else
                WriteLine("No");
            //Out.Flush();
        }
    }
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    //Fast_IO();
    string s,t; cin >> s >> t;
    ll n = len(s);
    ll cc = 0;
    f(i,0,n-1) if(s[i] != t[i]) cc++;
    cout << cc;
    return 0;
}

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

using namespace std;

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

    int a[100];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 3636
import sys
import numpy as np

N, M = (int(i) for i in input().split(" "))
S = [input().split(" ") for i in range(N + M)]

seito = S[0:N]
check = S[N:N+M]

kyori = np.zeros(M)

for j in range(0,N):
	for i in range(0,M):
		kyori[i] = abs(int(seito[j][0]) - int(check[i][0])) + abs(int(seito[j][1]) - int(check[i][1]))
	#kyoriが一番低いiを出力する

	num = np.argmin(kyori) + 1
	print(num)





Measured memory_bytes: 12492
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define gcd(a,b)	__gcd__(a,b)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0
const ll inf = (ll)1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int nCm[101][101];
ll pow2[10];

int main() {
	cin.tie(0);
	cin.sync_with_stdio(false);
	int n, m;	cin >> n >> m;
	ll ret = 100 * (n - m) + 1900 * m;
	rep(i, m)	ret *= 2;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 10 ** 15
for i in range(max(x, y) * 2 + 1):
  n = c * i * 2 + max(0, x - i) * a + max(0, y - i) * b
  ans = min(ans, n)
print(ans)  

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
using 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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  REP(i, N){
    cin >> C[i];
    REP(j, M){
      cin >> A[i][j];
    }
  }
  int ans = INF;
  REP(b, 1<<N){
    vector<int> v(M, 0);
    int cost = 0;
    REP(i, N){
      if(b>>i & 1){
        cost += C[i];
        REP(j, M){
          v[j] += A[i][j];
        }
      }
    }
    bool flag = true;
    REP(i, M){
      if(v[i] < X){
        flag = false;
      }
    }
    if(flag){
      ans = min(cost, ans);
    }
  }
  if(ans == INF){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  int s, w;
  cin >> s >> w;

  cout << (s <= w ? "unsafe": "safe") << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

#pragma warning (disable:4996)


typedef struct { char s[4]; }WETHER;

int main() {
	//文字列の入力
	WETHER wether = {};
	for (int i=0; i < 4; i++) {
		scanf("%c", &wether.s[i]);
	}

	//関数プロトタイプ
	int judge(WETHER);

	//出力
	int con;
	switch (judge(wether)) {
	case 0:
		con = 0;
		printf("%d", con);
		break;
	case 1:
		con = 1;
		printf("%d", con);
		break;
	case 2:
		con = 2;
		printf("%d", con);
		break;
	case 3:
		con = 3;
		printf("%d", con);
		break;
	}
}


//文字列の判定を行う関数
int judge(WETHER s) {
	if (s.s[0] == 'R') {
		if (s.s[1]=='R') {
			if (s.s[2]=='R') {
				return 3;  //RRR
			}
			else {
				return 2;  //RRS
			}
		}
		else {
			if (s.s[2] == 'R') {
				return 1;  //RSR
			}
			else {
				return 1;  //RSS
			}
		}
	}
	else {
		if (s.s[1] == 'R') {
			if (s.s[2] == 'R') {
				return 2;  //SRR
			}
			else {
				return 1;  //SRS
			}
		}
		else {
			if (s.s[2] == 'R') {
				return 1;  //SSR
			}
			else {
				return 0;  //SSS
			}
		}
	}
}


/*実行時間制限: 2 sec / メモリ制限 : 1024 MB
配点 : 100点

問題文
AtCoder町の、ある連続した3日間の天気の記録があります。
天気の記録は長さ3の文字列Sで表され、i(1≤i≤3) 日目の天気は i文字目が S のとき晴れ、R のとき雨でした。
天気が雨である日が連続していた最大の日数を求めてください。

制約
|S|= 3
Sの各文字は S または R である

入力
入力は以下の形式で標準入力から与えられる。
S

出力
天気が雨である日が連続していた最大の日数を出力せよ。

入力例 1
RRS

出力例 1
2
3日間のうち、1, 2 日目が雨で、最大では 2 日間雨である日が連続していたので2を出力してください。

入力例 2
SSS

出力例 2
0
3日間のうち、3 日とも晴れでした。雨である日は無かったため、0を出力してください。

入力例 3
RSR

出力例 3
1
3日間のうち、1, 3 日目が雨でした。共に 1 日雨である日が連続していたので、1 を出力してください。*/

Measured memory_bytes: 1644
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
#include <functional>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int n, c[200100];
vector<int> e[200100], chil[200100];

int r[200100], p[200100], q[200100];
int dfs(int x, int u, int euler, int depth) {
	r[x] = depth;
	p[x] = euler++;
	for (int next : e[x])
		if (next != u) {
			euler = dfs(next, x, euler, depth + 1);
			chil[x].emplace_back(next);
		}
	return (q[x] = euler);
}

constexpr int sz = 1 << 18;
int stree[sz*2];
int query(int l, int r, int low = 0, int upp = sz, int x = 0) {
	if (r <= low || upp <= l)
		return 0;
	if (l <= low && upp <= r)
		return stree[x];
	int cen = (low + upp) / 2;
	int lv = query(l, r, low, cen, x * 2 + 1);
	int rv = query(l, r, cen, upp, x * 2 + 2);
	return lv + rv;
}
void upd(int x, int v) {
	x += sz - 1;
	stree[x] = v;
	while (x != 0) {
		x = (x - 1) / 2;
		stree[x] = stree[x * 2 + 1] + stree[x * 2 + 2];
	}
}

vector<int> s[200100];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", c + i);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		e[a].emplace_back(b);
		e[b].emplace_back(a);
	}

	dfs(1, 0, 0, 0);
	for (int i = 0; i < n; i++)
		upd(i, 1);

	for (int i = 1; i <= n; i++)
		s[c[i]].emplace_back(i);
	for (int i = 1; i <= n; i++) {
		sort(s[i].begin(), s[i].end(), [](int a, int b) { return r[a] > r[b]; });

		ll total = 0;
		vector<ll> chunck;
		for (int x : s[i]) {
			for (int next : chil[x]) {
				int val = query(p[next], q[next]);
				chunck.emplace_back(val);
				total += val;
			}
			int val = query(p[x], q[x]);
			upd(p[x], -(val - 1));
		}
		int val = query(0, n);
		total += val;
		chunck.emplace_back(val);


		ll m = s[i].size(), res = 0;
		res += m * 2;
		res += m * (m - 1);
		res += m * (n - m) * 2;
		for (int i = 0; i < chunck.size(); i++)
			res += chunck[i] * (total - chunck[i]);

		for (int x : s[i])
			upd(p[x], 1);
		printf("%lld\n", res / 2);
	}
}

Measured memory_bytes: 57184
#include <iostream>
#include <algorithm>
using namespace std;
int a[1000006], b[1000006];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a + 1, a + 1 + n);
	int mid1 = a[n / 2], mid2 = a[n / 2 + 1];
	for (int i = 1; i <= n; ++ i)
		if (b[i] <= mid1)
			cout << mid2 << endl;
		else
			cout << mid1 << endl;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
ll st[4*300000+2];
void solve()
{
    ll n;  // Number of elements  
    cin>>n;
    
    pii p[n];
    
    for(ll i=0;i<n;i++)
    cin>>p[i].ff>>p[i].ss;
    
    sort(p,p+n);
    
    ll a[n];
    
    ll s[n];
    
    for(ll i=0;i<n;i++)
    s[i]=p[i].ff;
    
    ll l[n];
    
    for(ll i=0;i<n;i++)
    l[i]=i;
    
    for(ll i=0;i<n;i++){
        ll x=p[i].ff+p[i].ss;
        
        auto it=lower_bound(s,s+n,x);
        if(it==s)
        continue;
        
        it--;
        
        ll pos=it-s;
        l[i]=pos;
    }
    
    for(ll i=0;i<n;i++)
    a[i]=l[i];
    
    
    function<void(ll,ll,ll)>build_sgt=[&](ll ss,ll se,ll si){
        if(ss==se){
            st[si]=a[ss];
            return;
        }
        
        ll mid=(ss+se)/2;
        build_sgt(ss,mid,2*si+1);
        build_sgt(mid+1,se,2*si+2);
        st[si]=max(st[2*si+1],st[2*si+2]);
    };
    
    function<void(ll,ll,ll,ll,ll)>update=[&](ll ss,ll se,ll si,ll id,ll val){
      if(ss==se&&ss==id){
          st[si]=val;
          return;
      }
      
      if(id>se||id<ss)
      return;
      
      ll mid=(ss+se)/2;
      
      update(ss,mid,2*si+1,id,val);
      update(mid+1,se,2*si+2,id,val);
      
      st[si]=max(st[2*si+1],st[2*si+2]);
    };
    
    
    function<ll(ll,ll,ll,ll,ll)>get_min=[&](ll ss,ll se,ll si,ll l,ll r){
        
        if(l>r)
        
        return -INF;
        
        
        if(r<ss||se<l)
        return -INF;
        
        if(ss>=l&&se<=r)
        return st[si];
        
        ll mid=(ss+se)/2;
        
        return max(get_min(ss,mid,2*si+1,max(l,ss),min(mid,r)),get_min(mid+1,se,2*si+2,max(l,mid+1),min(se,r)));
    };
    
    build_sgt(0,n-1,0);
    ll dp[n+1];
    
    dp[n]=1;
    
    for(ll i=n-1;i>=0;i--){
        ll res=get_min(0,n-1,0,i,a[i]);
        a[i]=res;
        update(0,n-1,0,i,a[i]); 
    }
    for(ll i=n-1;i>=0;i--)
    dp[i]=(dp[i+1]+dp[a[i]+1])%mod;
     
     cout<<dp[0]<<endl;
   //  cout<<endl;
    
    
    
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
   //cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 17072
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    string s;
    cin >> s;

    int ans;

    // 最初を黒にする。
    int cnt = 0;
    REP(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] != '0')
                cnt++;
        } else {
            if (s[i] != '1')
                cnt++;
        }
    }
    ans = cnt;
    cnt = 0;
    REP(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] != '1')
                cnt++;
        } else {
            if (s[i] != '0')
                cnt++;
        }
    }

    ans = min(ans, cnt);

    cout << ans << endl;

    return 0;
}

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

typedef long long int ll;



int main () {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll minutes = 0;
    if (m1==0 && m2==0) {
    	minutes = (h2-h1)*60;
    }
    else if (m1==0 && m2!=0) {
    	minutes = ((h2-h1)*60) + m2;
    }
    else if (m1!=0 && m2==0) {
    	minutes = ((h2-h1-1)*60) + (60-m1);
    }
    else {
    	minutes = ((h2-h1-1)*60) + m2 + (60-m1);
    }

    cout << minutes-k << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int A, B;
  cin >> A >> B;
  if (A < 10 and B < 10) {
    cout << A * B << endl;
  } else {
    cout << "-1" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <limits>
#include <utility>
#include <string>
#include <numeric>

//find the shortest path and its distance with Dijkstra algorithm.

//if you would like this program to run faster, use pair or vector instead of map in Edge.
template<class T>
using Edge = std::map<std::string, T>; //for this algorithm, an edge must have "successor" and "cost" keys.
template<class T>
using Graph = std::vector<std::vector<Edge<T> > >;

//The id of a vertex in the graph must be in [0,V).
template<class T>
std::pair<std::vector<T>, std::vector<T> > Dijkstra(Graph<T> &graph, const T &start){
    const T V = graph.size();
    const T distanceSup = std::numeric_limits<T>::max();
    const T zero = static_cast<T>(0);

    std::vector<T> distance(V, distanceSup);
    std::vector<T> predecessor(V);
    std::vector<bool> isVisited(V, false);
    distance[start] = zero;
    std::iota(predecessor.begin(),predecessor.end(),zero);

    auto compare = [](const std::pair<T,T> &a, const std::pair<T,T> &b){
        return a.second > b.second;
    };
    std::priority_queue<std::pair<T,T>, std::vector<std::pair<T,T> >, decltype(compare)> queue(compare);
    queue.emplace(start,distance[start]);
    T pred, suc;
    T distTmp;
    while(!queue.empty()){
        pred = queue.top().first;
        if(isVisited[pred]){
            queue.pop();
            continue;
        }
        isVisited[pred] = true;
        queue.pop();

        if(distance[pred] == distanceSup){
            break;
        }

        for(auto &edge: graph[pred]){
            suc = edge["successor"];
            if(isVisited[suc]){
                continue;
            }
            distTmp = distance[pred] + edge["cost"];
            if(distance[suc] > distTmp){
                distance[suc] = distTmp;
                predecessor[suc] = pred;
                queue.emplace(suc,distance[suc]);
            }
        }        
    }

    return std::pair<std::vector<T>, std::vector<T> >(distance,predecessor);
}

int main(int argc, char *argv[]){
    long int N,M;
    std::cin >> N >> M;
    if(M<1){
        std::cout << -1 << std::endl;
        return 0;
    }
    long int u,v;
    Graph<long int> graph(3*N);
    Edge<long int> edge;
    for(long int i=0; i<M; ++i){
        std::cin >> u >> v;
        --u; --v;
        edge["successor"] = v+N;
        edge["cost"] = 1;
        graph[u].emplace_back(edge);
        edge["successor"] = v+2*N;
        edge["cost"] = 1;
        graph[u+N].emplace_back(edge);
        edge["successor"] = v;
        edge["cost"] = 1;
        graph[u+2*N].emplace_back(edge);
    }
    long int S,T;
    std::cin >> S >> T;
    --S; --T;

    auto dijkstra = Dijkstra(graph, S).first[T];
    if(dijkstra < std::numeric_limits<long int>::max()){
        std::cout << dijkstra/3 << std::endl;
    }else{
        std::cout << -1 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 72960