akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
#define pll pair<ll, ll>

// 二項係数

const int MAX = 510000; // MAX = 510000でも10e7までできる。計算量注意。
ll MOD = pow(10, 9) + 7;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    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;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0)
        return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}

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

    ll X, Y;
    cin >> X >> Y;
    combination_init();

    ll ans = 0;
    for (ll b = 0; 2 * b <= X; b++) {
        ll a = X - 2 * b;
        if (2 * a + b == Y) {
            ans += combination2(a + b, a);
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 15608
#include <stdio.h>

int field[8][8];

char check_panel(int i, int j)
{
	if (field[i][j + 1] == 1){
		if (field[i][j + 2] == 1){
			return 'C';
		}
		else if (field[i + 1][j] == 1){
			if (field[i + 1][j + 1] == 1){
				return 'A';
			}
			else {
				return 'G';
			}
		}
		else {
			return 'E';
		}
	}
	else {
		if (field[i + 2][j] == 1){
			return 'B';
		}
		else {
			if (field[i + 1][j + 1] == 1){
				return 'F';
			}
			else {
				return 'D';
			}
		}
	}
}

int main(void)
{
	
	char c;
	int i, j;
	int flag;
	
	while (1){
		for (i = 0; i < 8; i++){
			for (j = 0; j < 8; j++){
				if (scanf("\n%c", &c) == EOF){
					return 0;
				}
				field[i][j] = c - '0';
			}
		}
		
		for (i = 0; i < 8; i++){
			for (j = 0; j < 8; j++){
				if (field[i][j] == 1){
					printf("%c\n",check_panel(i, j));
					flag = 1;
					break;
				}
			}
			if (flag == 1){
				flag = 0;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 540
# ABC105B - Cakes and Donuts
def main():
    N = int(input())
    if N % 4 == 0 or N % 7 == 0:
        print("Yes")
    elif N < 4:
        print("No")
    else:
        while N > 7:
            N -= 4
            if N % 4 == 0 or N % 7 == 0:
                print("Yes")
                return
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L, min(L+2018 , R)):
    for j in range(i+1, min(L+2019, R+1) ):
        a = ( i * j ) % 2019
        ans = min(a, ans)
   
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

map<int,int> n1,n2;

int main() {
    int n;
    cin>>n;
    
    int x;
    rep(i,n) {
        cin>>x;
        if(i%2==0) {
            n1[x]++;
        }else {
            n2[x]++;
        }
    }
    
    vector<pair<int,int>> p1,p2;
    
    for(auto a:n1) {
        p1.push_back({-a.second,a.first});
    }
    for(auto a:n2) {
        p2.push_back({-a.second,a.first});
    }
    
    p1.push_back({0,0});
    p2.push_back({0,0});
    
    sort(p1.begin(),p1.end());
    sort(p2.begin(),p2.end());
    
    
    
    
    if ( p1[0].second != p2[0].second) {
        cout<< (n + p1[0].first + p2[0].first )<<endl;
    } else {
        int b = min( p1[1].first, p2[1].first);
        cout<< (n + p1[0].first + b )<<endl;
    }
}

Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int dan=1;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++){
      cin >> a.at(i);}
  sort(a.begin(), a.end());
  reverse(a.begin(),a.end());

  for (int i=0; i<N-1; i++){
      if(a.at(i)>a.at(i+1)){
          dan ++; }
  }
  cout << dan << endl;
}

Measured memory_bytes: 256
a = int(input())
b = [int(i) for i in input().split()]
maxcount = 0
maxindex = 0
count = 0
ind = 0
prev = -float('inf')
for index, val in enumerate(b):
    if val <= prev:
        count += 1
        if count > maxcount:
            maxcount = count
            maxindex = ind
    else:
        count = 0
        ind = index
    prev = val
print(maxcount)

Measured memory_bytes: 14252
/////16:35~
/////B:16:42
/////C:

#include<iostream>
#include<vector>
#include<algorithm>

int S[1010];
int k[1010];
int Nmax[10101];
int Nmin[10101];
using namespace std;
int main(){
    while(true){
        int N,M;
        cin>>N>>M;
        if(N==0)return 0;
        for(int i =0;i<=N;i++){
            Nmin[i]=0;
            Nmax[i]=0;
        }
        vector<vector<int> > c(M+1);
        for(int i = 1;i<=M;i++){
            cin>>S[i]>>k[i];
            for(int j=1;j<=k[i];j++){
                int tmp;
                cin>>tmp;
                c[i].push_back(tmp);
                Nmax[tmp]+=S[i];
            }
            if(k[i]==1){
                Nmin[c[i][0]]+=S[i];
            }
        }
        int min1=1e9,min2=1e9,ans=0,minpos=0;
        for(int i =1;i<=N;i++){
            if(Nmin[i]<=min1){
                min1 = Nmin[i];
                minpos = i;
            }
        }
        for(int i =1;i<=N;i++){
            if(Nmin[i]<=min2){
                if(i!=minpos){
                    min2 = Nmin[i];
                }
            }
        }
        for(int i =1;i<=N;i++){
            if(i == minpos){
                ans = max(ans,Nmax[i]-min2);
            }else{
                ans = max(ans,Nmax[i]-min1);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n, ans;

vector <int> a(N);

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int was = 1;
    while (was) {
        was = 0;
        for (int i = 1; i <= n; ++i) {
            if (a[i] == i) {
                if (i == n)
                    swap(a[i], a[i - 1]);
                else
                    swap(a[i], a[i + 1]);
                ++ans;
                was = 1;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
int main()
{
	int64_t n;
	std::cin >> n;
	std::vector<int64_t> vals;
	vals.reserve(n);
	std::map<int64_t,int64_t> result;

	for (int64_t i = 0; i <n-1; ++i) {
		int64_t v = 0;
		std::cin >> v;
		vals.emplace_back(v);
		result[i + 1] = 0;
	}
	for (const auto& v : vals) {
		result[v]++;
	}
	for (const auto& v : result) {
		std::cout << v.second << "\n";
	}

	std::cout << "0\n";
}


Measured memory_bytes: 16788
n=int(input())
S=[input() for i in range(n)]
M=int(input())
T=[input() for i in range(M)]

from collections import Counter
CS=Counter(S)
CT=Counter(T)

ANS=0
for i in CS:
    if CS[i]-CT[i]>ANS:
        ANS=CS[i]-CT[i]

print(ANS)

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

int mod;
const int N = 1e5+5;
vector<int> G[N], child[N];
vector<pll> prv[N], suf[N];
pll down[N], up[N];
// (all_white, sth_is_black)
// omnidirectional dp( O(n) )


int add(int a, int b){
	return (a + b) % mod;
}
int mul(int a, int b){
	return (ll)a * b % mod;
}

pll merge(const pll& a,const pll& b){
	// calculate subtrees, not considering the root
	pll p;
	p.F = mul(a.F, b.F);
	p.S = add(mul(a.S, add(b.F, b.S)), mul(a.F, b.S));
	return p;
}

pll ans(const pll& a){
	pll p;
	p.F = a.F;
	p.S = add(a.F, a.S);
	return p;
}
void dfs1(int a, int parent) {
	pll p = {1, 0};
	for(int b : G[a]){
		if(b != parent){
			child[a].pb(b);
			dfs1(b, a);
			p = merge(p, down[b]);
		}
	}
	
	down[a] = ans(p);
}

void dfs2(int a, int parent){
	rep(i, SZ(child[a])){
		pll p{1, 0};
		if(i != 0)	p = merge(p, prv[a][i-1]);
		if(i != SZ(child[a]) - 1)	p = merge(p, suf[a][i+1]);
		if(a != 1)	p = merge(p, up[a]);
		up[child[a][i]] = ans(p);
		dfs2(child[a][i], a);
	}
}

// O((1+2+1) * n)
// print : O(n)
signed main(){
	IOS
	int n;
	scanf("%d%d", &n, &mod);
	rep(i,n-1){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].pb(b);
		G[b].pb(a);
	}
	dfs1(1, -1);

	// calculate prefix sums and suffix sums
	for(int a = 1; a <= n; a++){
		pll p{1, 0};
		for(int b = 0; b < SZ(child[a]); b++){
			p = merge(p, down[child[a][b]]);
			prv[a].pb(p);
		}
		p = {1, 0};
		for(int b = SZ(child[a]) - 1; b >= 0; b--){
			p = merge(p, down[child[a][b]]);
			suf[a].pb(p);
		}
		reverse(suf[a].begin(), suf[a].end());
	}
	dfs2(1, -1);
	for(int a = 1; a <= n; a++){
		pll p{1, 0};
		if(a != 1)	p = merge(p, up[a]);
		if(!child[a].empty())	p = merge(p, prv[a].back());
		p = ans(p);
		printf("%lld\n", p.S);
	}

}


Measured memory_bytes: 32128
function Main(input) {
  "use strict";
	const lines = input.split("\n");
  const n = parseInt(lines[0], 10);
  const vs = lines[1].split(" ").map(s => parseInt(s, 10));
  const cs = lines[2].split(" ").map(s => parseInt(s, 10));
  const diffs = vs.map( (v, i) => v - cs[i]).filter(d => d > 0)
    
  console.log(diffs.reduce((acc, d) => acc + d, 0))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll a[n];rep(i,0,n)cin>>a[i];
  ll q;cin>>q;
  ll b[q];rep(i,0,q)cin>>b[i];

  bool e[q];CLR(e,false);
  vector<bool>ans;
  rep(bit,0,(1<<n)){
    ll sum=0;
    rep(i,0,n){
      if((bit>>i)&1)sum+=a[i];
    }

    rep(i,0,q){
      if(sum==b[i])e[i]=true;
    }
  }
  rep(i,0,q){
    if(e[i])out("yes");
    else out("no");
  }



  return 0;
}



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


int main(){
    int n;
    cin>>n;
    int x=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    cout<<abs(a[n/2]-a[n/2-1]);

    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y, m;
string s, t;

ll rem;
ll cnt[3];


// < ----------- func eh ---------------- ? //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s ;
	for(ll i=0;i<s.length();i++) {
		if(i&1) {
			if(s[i] == 'R') {
				cout<<"No\n";
				return;
			}
		}
		else {
			if(s[i] == 'L') {
				cout<<"No\n";
				return;
			}
		}
	}
	cout<<"Yes\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int X, Y, Z, K;
vec<int> A, B, C;
vec<int> cand;
vec<int> ans;

void solve() {
  rep (i, cand.size()) {
    rep (j, Z) {
      ans.push_back(cand[i] + C[j]);
      if (ans.size() >= min(X*Y*Z, K+(int)1e7)) {
        sort(all(ans)); reverse(all(ans));
        return;
      }
    }
  }
}

signed main() {
  cin >> X >> Y >> Z >> K;
  A.resize(X);
  B.resize(Y);
  C.resize(Z);
  rep (i, X) { cin >> A[i]; }
  rep (i, Y) { cin >> B[i]; }
  rep (i, Z) { cin >> C[i]; }

  rep (i, X) {
    rep (j, Y) {
      cand.push_back(A[i] + B[j]);
    }
  }
  sort(all(cand)); reverse(all(cand));
  sort(all(C)); reverse(all(C));

  solve();

  rep (i, K) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 141664
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N,M;
  cin >> N >> M;
  // N要素の配列で初期化
  vector<int> vec(N);
 
  // N個の入力を受け取る
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
int i;
double sum=0;
for(i=0; i<N; i++){
sum=sum+vec[i];
}
//cout << sum << endl;
sort(vec.rbegin(),vec.rend());
  //cout << vec.at(M-1) << endl;
  //cout << sum/(4*M) << endl;
if(vec.at(M-1) >= sum/(4*M)){
  cout << "Yes" << endl;
}
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <istream>
#include <vector>

int main(int argc, char **argv){

    std::vector<std::string> v;
    std::string buf;
    while(std::cin >> buf){
	v.push_back(buf);
    }

    std::string s;
    std::vector<long> stack(101);
    int pt = 0;
    for(int i = 0; i < v.size(); i++){
	s = v.at(i);
	if(s == "+"){
	    long v0 = stack.at(pt-2); long v1 = stack.at(pt-1);
	    long v2 = v0 + v1;
	    stack.at(pt-2) = v2;
	    pt = pt-2+1;
	}else if(s == "-"){
	    long v0 = stack.at(pt-2); long v1 = stack.at(pt-1);
	    long v2 = v0 - v1;
	    stack.at(pt-2) = v2;
	    pt = pt-2+1;
	}else if(s == "*"){
	    long v0 = stack.at(pt-2); long v1 = stack.at(pt-1);
	    long v2 = v0 * v1;
	    stack.at(pt-2) = v2;
	    pt = pt-2+1;
	}else if(s != "" && s != "\n"){
	    long v0 = std::stol(s);
	    stack.at(pt) = v0;
	    pt = pt + 1;
	}
    }

    std::cout << stack.at(0) << std::endl;


    

}



Measured memory_bytes: 3180
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    int n=0, i=1;
    while (true) {
        cin >> n;
        if (n == 0) break;
        cout << "Case " << i << ": " << n << endl;
        i++;
    }
    return 0;		 
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>

using namespace std;

bool exec(string s)
{
  string first(s.begin(), s.begin() + (s.size()) / 2);
  string second(s.begin() + (s.size() + 3) / 2 - 1, s.end());
  reverse(second.begin(), second.end());

  return first.compare(second) == 0;
}

int main()
{
  string s;

  cin >> s;

  string first(s.begin(), s.begin() + (s.size() - 1) / 2);
  string second(s.begin() + (s.size() + 3) / 2 - 1, s.end());

  if (!exec(s) || !exec(first) || !exec(second))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int max = n - k;
    if(k == 1){
        max = 0;
    }
    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
binN = format(N, "b").zfill(60)
mod = 7 + 10 ** 9

DP = [[0, 0, 0] for _ in range(60)]
if binN[0] == "0":
    DP[0] = [1, 0, 0]
else:
    DP[0] = [1, 1, 0]

for i in range(1, 60):   
    if binN[i] == "0":
        DP[i][0] = (DP[i-1][0] + DP[i-1][1]) % mod
        DP[i][1] = DP[i-1][1]
        DP[i][2] = (DP[i-1][2] * 3 + DP[i-1][1]) % mod
    else:
        DP[i][0] = DP[i-1][0]
        DP[i][1] = (DP[i-1][0] + DP[i-1][1]) % mod
        DP[i][2] = (DP[i-1][2] * 3 + DP[i-1][1] * 2) % mod
print(sum(DP[-1]) % mod)



Measured memory_bytes: 3064
r,c = map(int, input().split())
matrix = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
  l = list(map(int, input().split()))
  for j in range(c):
    matrix[i][j] += l[j]
    matrix[i][c] += matrix[i][j]
    matrix[r][j] += matrix[i][j]
    matrix[r][c] += matrix[i][j]
  print(" ".join(map(str, matrix[i])))
print(" ".join(map(str, matrix[r])))


Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;

int main(){
	IOS
	int a;
	cin >> a;
	cout << (a+1)/2 << endl;
}

Measured memory_bytes: 3608
'use strict'
function Main(input){
  var M=Math.pow(2,50);
  const K=998244353;
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var sum=input.reduce((a,c)=>a+c);
  var half=Math.floor(sum/2);
  
  var dp=[];
  //dp[i][j]でinput[0~i]のうち任意個のg,bを使って合計をjにする場合の数
  for(let i=0;i<=N;i++){
    dp[i]=[];
    for(let j=0;j<=half;j++){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(let i=0;i<N;i++){
    for(let j=0;j<=half;j++){
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=K;
      if(j+input[i]<=half){
        dp[i+1][j+input[i]]+=2*dp[i][j];
        dp[i+1][j+input[i]]%=K;
      }
    }
  }
  
  var ans=1;
  for(let i=0;i<N;i++){
    ans*=3;
    ans%=K;
  }
  dp[N].forEach(function(x,i,arr){
    ans-=3*x;
  });
  
  var DP=[];
  //DP[i][j]でinput[0~i]のうち任意個のgを使って合計をjにする場合の数
  for(let i=0;i<=N;i++){
    DP[i]=[];
    for(let j=0;j<=half;j++){
      DP[i][j]=0;
    }
  }
  DP[0][0]=1;
  for(let i=0;i<N;i++){
    for(let j=0;j<=half;j++){
      DP[i+1][j]+=DP[i][j];
      DP[i+1][j]%=K;
      if(j+input[i]<=half){
        DP[i+1][j+input[i]]+=DP[i][j];
        DP[i+1][j+input[i]]%=K;
      }
    }
  }
  
  if(sum%2===0){
    ans+=3*DP[N][half];
    ans%=K;
  }
  ans%=K;
  ans+=K;
  ans%=K;
  console.log(ans);
}

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


Measured memory_bytes: 267128
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

pi=3.14159265358979

def main():
	a = int(input())
	print(a*2*pi)
	#b , c = IN()
	#s = input()
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  vector<string> c(h);
  rep(i, h) {
    cin >> c[i];
  } 
  rep(i, h) {
    rep(j, 2) {
      cout << c[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define rep2(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, 0, n - 1) {
		if (a[i] == 0) continue;
		if (a[i] == a[i + 1]) {
			ans++;
			a[i + 1] = 0;
		}
	}
	cout << ans << endl;
}

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

int grundy[201][101];

int dfs(int w, int b){
    if(grundy[w][b] >= 0){
        return grundy[w][b];
    }

    set<int> st;
    if(w > 0){
        st.insert(dfs(w - 1, b));
    }
    if(b > 0){
        st.insert(dfs(w + 1, b - 1));
    }
    for(int i = 1 ; i <= b && i <= w ; ++i){
        st.insert(dfs(w, b - i));
    }

    int res = 0;
    while(st.count(res)){
        ++res;
    }

    return grundy[w][b] = res;
}

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

    fill(grundy[0], grundy[201], -1);
    grundy[0][0] = 0;

    int n;
    cin >> n;

    int v = 0;
    for(int i = 0 ; i < n ; ++i){
        int w, b;
        cin >> w >> b;
        v ^= dfs(w, b);
    }

    if(v == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3288
//Volume2-0207
import java.util.ArrayDeque;
import java.util.Scanner;

class Cell {
	public int x,y;
	Cell(int x,int y){
		this.x=x; this.y=y;
	}
}

class Main {

	private static final int              MARK      = 9;
	private static       int	          w,h,color;
	private static final int[][]          chk       = {{-1,0},{0,-1},{1,0},{0,1}};
	private static       int[][]          board;
	private static       ArrayDeque<Cell> q         = new ArrayDeque<Cell>();

	public static void main(String[] args){

		int xs,ys,xg,yg,n;
		String result;

		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0&&h==0){break;}
			result = "";
			board = new int[h][w];
			xs = sc.nextInt()-1; ys = sc.nextInt()-1;
			xg = sc.nextInt()-1; yg = sc.nextInt()-1;
			n  = sc.nextInt();
			for(int i=0;i<n;i++){
				paint(sc.nextInt(),sc.nextInt(),sc.nextInt()-1,sc.nextInt()-1);
			}
			if   (search(xs,ys,xg,yg)){result = "OK";}
			else                      {result = "NG";}
			System.out.println(result);
		}
	}

	private static void paint(int c,int d,int x,int y){
		for(int i=0;i<4;i++){
			for(int j=0;j<2;j++){
				if(d==1){
					board[y+i][x+j] = c;
				} else {
					board[y+j][x+i] = c;
				}
			}
		}
	}

	private static boolean search(int xs,int ys,int xg,int yg){

		boolean ret = false;

		color = board[ys][xs];
		q.clear();
		q.add(new Cell(xs,ys));

		while(!q.isEmpty()){
			Cell cl = q.poll();
			if(cl.x==xg&&cl.y==yg){
				ret = true;
				break;
			}else {
				board[cl.y][cl.x] = MARK;
				setAroundCell(cl);
			}
		}
		return ret;
	}

	private static void setAroundCell(Cell cl){
		int x,y;
		for(int i=0;i<4;i++){
			x = cl.x+chk[i][0];
			y = cl.y+chk[i][1];
			if(0 <= y && y < h && 0 <= x && x < w){
				if(board[y][x] == color){
					q.add(new Cell(x,y));
				}
			}
		}
	}
}

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

int main(){

    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];

    vector<vector<long long> > dp(3, vector<long long>(N, -1));
    dp[0][0] = a[0], dp[1][0] = b[0], dp[2][0] = c[0];
    for(int i = 1; i < N; i++){
        dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
        dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
        dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
    }

    cout << max(dp[0][N - 1], max(dp[1][N - 1], dp[2][N - 1])) << endl;

    return 0;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include <algorithm>

int main(int argc, char const *argv[]) {
	int N, A, B;
	int P[101];
	int i;

	scanf("%d", &N);
	scanf("%d %d", &A, &B);
	for (i = 1; i <= N; i++) {
		scanf("%d", &P[i]);
	}

	std::sort(P+1, P+1+N);

	int p[3] = {};

	for (i = 1; i <= N && P[i] <= A; i++) ;
	p[0] = i-1;

	for (i = p[0]+1; i <= N && P[i] <= B; i++) ;
	p[1] = i-p[0]-1;

	p[2] = N - p[0] - p[1];

	int ans;

	// printf("%d %d %d\n", p[0], p[1], p[2]);

	if (p[0] < p[1]) {
		ans = p[0] < p[2] ? p[0] : p[2];
	} else {
		ans = p[1] < p[2] ? p[1] : p[2];
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
const int INF = 0x3f3f3f3f;
//static const auto _____ = []()
//{
//	ios::sync_with_stdio(false);
//	cin.tie(nullptr);
//	return nullptr;
//}();

int main(int argc, char *argv[]) {
    int N, K;
    cin >> N >> K;
    vector<int> h(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    vector<int> dp(N + 1, INF);
    dp[1] = 0;
    for(int i=2;i<=N;i++){
        for(int j=max(i-K,1);j<i;j++){
            dp[i] = min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
//    for (int i = 3; i <= N; i++) {
//        int tmp = INF;
//        for (int k = 1; k <= K; k++) {
//            if (i - k < 0) break;
//            tmp = min(tmp, dp[i - k] + abs(h[i] - h[i - k]));
//        }
//        dp[i] = tmp;
//    }
    cout << dp[N];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<set>
#include<map>
#include<stack>
#define i64 long long
#define vi32 vector<int>
#define vi64 vector<long long>
#define  ii pair<i64,i64>
const long long mod = 1000000007LL, inf = 1e9, linf = 1e18;
using namespace std;
#define pb push_back
#define mp make_pair
#define N 1000005	
using namespace std;

int ckmin[N];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int l, r;
		cin >> l >> r;
		ckmin[l] += 1;
		ckmin[r + 1] -= 1;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ckmin[i] += ckmin[i - 1];
	}
	for (int i = 1; i <= n; i++)
	{
		if (ckmin[i] == m)
			ans++;
	}
	cout << ans;
}


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

#pragma warning(disable : 4996)

#define INF 1000000000.0

using namespace std;

int n, m, p, a, b, x, y, z, t[8];

double dp[256][30];

vector<pair<int, int> > G[30];

int main()
{
	while (true)
	{
		scanf("%d", &n);
		scanf("%d", &m);
		scanf("%d", &p);
		scanf("%d", &a);
		scanf("%d", &b);
		
		if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0) break;

		for (int i = 0; i < m; i++) G[i].clear();

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

		for (int i = 0; i < p; i++)
		{
			scanf("%d", &x);
			scanf("%d", &y);
			scanf("%d", &z);

			G[x - 1].push_back(make_pair(y - 1, z));
			G[y - 1].push_back(make_pair(x - 1, z));
		}

		for (int i = 0; i < (1 << n); i++)
		{
			for (int j = 0; j < m; j++)
			{
				dp[i][j] = INF;
			}
		}

		dp[0][a - 1] = 0.0;

		for (int i = 1; i < (1 << n); i++)
		{
			for (int j = 0; j < n; j++)
			{
				if (i & (1 << j))
				{
					for (int k = 0; k < m; k++)
					{
						for (int l = 0; l < G[k].size(); l++)
						{
							int node = G[k][l].first;

							double dist = G[k][l].second * 1.0 / t[j];

							dp[i][node] = min(dp[i][node], dp[i - (1 << j)][k] + dist);
						}
					}
				}
			}
		}

		double ret = INF;

		for (int i = 0; i < (1 << n); i++)
		{
			ret = min(ret, dp[i][b - 1]);
		}

		if (ret != INF)
		{
			printf("%.12f\n", ret);
		}
		else
		{
			printf("Impossible\n");
		}
	}

	return 0;
}

Measured memory_bytes: 3156
import java.util.Scanner;

//The Balance
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int a = sc.nextInt(), b = sc.nextInt(), d = sc.nextInt();
			if((a|b|d)==0)break;
			int ax = -1, ay = -1;
			int x = 0, t = d;
			while(t%b!=0){
				t+=a; x++;
			}
			int y = t/b;
			ax = x; ay = y;
			y = 0; t = d;
			while(t%a!=0){
				t+=b; y++;
			}
			x = t/a;
			if(x+y<ax+ay||x+y==ax+ay&&a*x+b*y<a*ax+b*ay){
				ax = x; ay = y;
			}
			t = 0; x = 0;
			for(;t<=d;){
				if((d-t)%b==0){
					y = (d-t)/b;
					if(x+y<ax+ay||x+y==ax+ay&&a*x+b*y<a*ax+b*ay){
						ax = x; ay = y;
					}
				}
				x++; t+=a;
			}
			System.out.println(ax+" "+ay);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>

using namespace std;

int main()
{
        int a,b;
        int res;

        scanf("%d %d", &a, &b);

        res = a+b > a*b ? a+b : a*b;

        res = res > a-b ? res : a-b;

        cout << res << endl;

        return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

struct UnionFind{
  vector<int> p;
  UnionFind(int n) : p(n,-1) {}

  int root(int x){
    if(p[x] < 0) return x;
    return p[x] = root(p[x]);
  }

  bool issame(int x,int y){
    return root(x) == root(y);
  }

  bool merge(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(p[x] > p[y]) swap(x,y);
    p[x] += p[y];
    p[y] = x;
    return true;
  }
};

using tup = tuple<int,int,int>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<tup> suzu(N);
  for(int i=0; i<N; i++){
    int x,y;
    cin >> x >> y;
    suzu[i] = tup(x,y,i);
  }
  priority_queue<tup,vector<tup>,greater<tup>> que;
  sort(suzu.begin(),suzu.end());
  for(int i=1; i<N; i++){
    int x1,y1,id1;
    tie(x1,y1,id1) = suzu[i-1];
    int x2,y2,id2;
    tie(x2,y2,id2) = suzu[i];
    que.emplace(x2-x1,id1,id2);
    suzu[i-1] = tup(y1,x1,id1);
    if(i == N-1){
      suzu[i] = tup(y2,x2,id2);
    }
  }
  sort(suzu.begin(),suzu.end());
  for(int i=1; i<N; i++){
    int x1,y1,id1;
    tie(x1,y1,id1) = suzu[i-1];
    int x2,y2,id2;
    tie(x2,y2,id2) = suzu[i];
    que.emplace(x2-x1,id1,id2);
  }
  UnionFind uf(N);
  ll ans = 0;
  while(que.size()){
    int cost,a,b;
    tie(cost,a,b) = que.top();
    que.pop();
    if(uf.issame(a,b)) continue;
    ans += cost;
    uf.merge(a,b);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 7548
#include<bits/stdc++.h>
using namespace std;
int v[200001];
int main(){
  int n,ans=0;
  cin >> n;

  for(int i=1;i<=n;i++){
    int a;
    cin >> a;
    v[a]++;
  }
  for(int i=-1;i<=100001;i++)ans=max(ans,v[i]+v[i-1]+v[i+1]);
  cout << ans << endl;
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	string s1;
	cin>>s1;
	stack<char> s;
	for(int i=0; i<n; i++)
	{
		if(s.empty())
		{	s.push(s1[i]);
			continue;
		}
		if(s.top()==s1[i])
			continue;
		else
			s.push(s1[i]);
	}
	cout<<s.size();
	return 0;
}
	

Measured memory_bytes: 512
q,h,s,d = map(int,input().split())
n = int(input())
litter = [q*4,h*2,s]
litter.sort()
twolitter = [q*8,h*4,s*2,d]
twolitter.sort()
total = 0
if n%2 == 0:
	total = (n//2)*twolitter[0]
else:
	total = (n//2)*twolitter[0]+litter[0]

print(total)

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	int n, r;
	cin >> n >> r;
	if(n >= 10) {
		cout << r << "\n";
	}
	else {
		cout << r + (100 * (10 - n)) << "\n";
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

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

int main() {
    int a, b, ans;
    cin >> a >> b;
    ans = a * b;
    cout << ans << endl;

}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

#define MOD 1000000007
#define INF 1050000000

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

	int x0=0,y0=0,x1=0,y1=0;

	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == '0') {
				x0++;
			}
			else {
				y0++;
			}
		}
		else {
			if (s[i] == '0') {
				x1++;
			}
			else {
				y1++;
			}
		}
	}

	cout << min({ x0 + y0,x1 + y0,x0 + y1,x1 + y1 }) << endl;




}

Measured memory_bytes: 512
#include <bitset> // compact STL for Sieve, better than vector<bool>!
#include <vector>
#include <cstdio>
#include <iostream>
#define ll long long
#define vi vector<int>

using namespace std;

ll _sieve_size; // ll is defined as: typedef long long ll;
bitset<10000010> bs; // 10^7 should be enough for most cases
vi primes; // compact list of primes in form of vector<int>
void sieve(ll upperbound) { // create list of primes in [0..upperbound]
_sieve_size = upperbound + 1; // add 1 to include upperbound
bs.set(); // set all bits to 1
bs[0] = bs[1] = 0; // except index 0 and 1
for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
// cross out multiples of i starting from i * i!
for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
primes.push_back((int)i); // add this prime to the list of primes
} } // call this method in main method
bool isPrime(ll N) { // a good enough deterministic prime tester
if (N <= _sieve_size) return bs[N]; // O(1) for small primes
for (int i = 0; i < (int)primes.size(); i++)
if (N % primes[i] == 0) return false;
return true; // it takes longer time if N is a large prime!
} // note: only work for N <= (last prime in vi "primes")^2
// inside int main()
int main()
{
    int TestCase,x;
sieve(1000010); // can go up to 10^7 (need few seconds)

    while(cin >> TestCase)
    {
        x=0;
        while(TestCase >= primes[x])
        {
            x++;
        }
        cout << x << endl;
    }
}

Measured memory_bytes: 2808
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238

typedef pair<int, int> P;

class UnionFind {
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;
    //つくるときはParentの値をすべて-1にする
    //こうするとすべてバラバラになる
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//親をとってきたい
    }
    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if(A == B) {
            //すでにくっついてるからくっつけない
            return false;
        }
        //大きい方（A）に小さいほう（B）をくっつけたい。
        //大小が逆だったらひっくり返しちゃう。
        if(size(A)<size(B)) swap(A,B);

        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;

        return true;
    } 
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin>>n>>m;
    vector<int> p(n);
    REP(i,n) cin>>p[i];
    UnionFind uf(n);
    int ans = 0;
    REP(i,m){
        int x,y; cin>>x>>y;
        uf.connect(x-1,y-1);
    }
    REP(i,n){
        if(uf.root(i)==uf.root(p[i]-1)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n,q,t,f;
	string st;
	char c;
	cin >> st;
	list<char>ls;
	for (auto& i : st) {
		ls.push_back(i);
	}
	cin >> q;
	ll revc = 0;
	while (q--) {
		cin >> t;
		if (t == 1) {
			revc++;
		}
		else {
			cin >> f >> c;
			if (revc & 1)
				f = 3 - f;
			if (f == 1)
				ls.push_front(c);
			else
				ls.push_back(c);
		}
	}
	if (revc & 1)
		ls.reverse();
	for (auto& i : ls) {
		cout << i;
	}
	return 0;
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
typedef unsigned long long int ull;
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    ull n,a[100001],p=1;
    cin>>n;
    for (ull i = 0; i < n; i++)
    {
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
        
    }
    for (ull i = 0; i < n; i++)
    {
        if(a[i]<=1000000000000000000/p){
            p*=a[i];
        }else{
             cout<<-1<<endl;
            return 0;
        }
      
    }
    
    
    cout<<p<<endl;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	

   return 0;
}


Measured memory_bytes: 4444
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll N;
	cin >> N;
	vector<P> P(N);
	REP(i, N) {
		cin >> P[i].first;
		P[i].second = i + 1;
	}
	sort(P.rbegin(), P.rend());

	ll ans = 0;
	multiset<ll> s;
	s.insert(0);
	s.insert(0);
	s.insert(N + 1);
	s.insert(N + 1);
	for (auto one : P) {
		auto it = s.lower_bound(one.second);
		ll posR = *it;
		it++;
		ll posRR = *it;
		it--;
		it--;
		ll posL = *it;
		it--;
		ll posLL = *it;

		ll ansOneL = one.first * (posL - posLL) * (posR - one.second);
		ll ansOneR = one.first * (posRR - posR) * (one.second - posL);
		ans += ansOneL;
		ans += ansOneR;

		s.insert(one.second);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6528