akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }



void solve() {
    int n; cin >> n;
    if(n == 1) {
        cout << 0 << endl; return;
    }
    vector<int> v;
    bool is = true;
    for(int i=2; i*i<=n; i++) if(n % i == 0) {
        is = false; break;
    }
    if(is) {
        cout << 1 << endl; return;
    }
    int x = n;
    int lim = 1e6;
    for(int i=2; i<=min(lim,x); i++) {
        if(x % i == 0) {
            int cnt = 0;
            while(x % i == 0) {
                cnt++;
                x /= i;
            }
            v.push_back(cnt);
        }
    }
    if(x != 1) v.push_back(1);
    int ans = 0;
    for(int a : v) {
        int i=1; 
        while(i*(i+1)/2 <= a) {
            i++;
        }
        i--;
        ans += i;
    }
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	double i,j;
	cin>>i>>j;
	cout<<i/j<<endl;
	
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int A[N+1], B;
    long ans = 0;
    rep(i, N+1) cin >> A[i];
    rep(i, N) {
        cin >> B;
        int t = 0;
        t = min(A[i] + A[i+1], B);
        ans += t;
        A[i+1] -= t - min(A[i], B);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
ll n,ans,t,a,b,c,d;
const int inf=1e9;
bool jud(ll a,ll b,ll c,ll d){
	if (a<b) return 0;
	if (d<b) return 0;
	if (c>=b) return 1;
	ll t=a%b,s=__gcd(b,d);
	t+=(b-1-t)/s*s;
	return t<=c; 
}
int main(){
	scanf("%d",&t);
	rep(i,1,t){
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if (jud(a,b,c,d)) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define EPS 1e-9

int d[300];
int main(){
	int n,k,t,u,v,l;
	scanf("%d%d%d%d%d%d",&n,&k,&t,&u,&v,&l);
	rep(i,0,n)scanf("%d",d+i);
	double ans=0;
	int crr=0,cnt=0;
	double time=0;
	rep(i,0,l){
		if(d[crr]==i)cnt++,crr++;
		if(fabs(time)<EPS&&cnt>0)time=t,cnt--;
		if(cnt>k)cnt=k,time=t;
		ans+=time>EPS?1./v:1./u;
		if(time>EPS)time-=1./v;
	}
	printf("%.9f\n",ans);
}


Measured memory_bytes: 2112
#include<stdio.h>

int main(void) {
  int a, b;

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

  if(a<b)
    printf("a < b\n");
  else if(a>b)
    printf("a > b\n");
  else
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
END { load __FILE__ unless $stdin.eof? }

n, m = gets.split.map!(&:to_i)

nbrs = Array.new(n + 1) { [] }
m.times do
  a, b = gets.split.map!(&:to_i)
  nbrs[a] << b
  nbrs[b] << a
end

q = [1]
dir = Array.new(n + 1)
dir[0] = dir[1] = 0
while (x = q.shift)
  nbrs[x].each do |y|
    next if dir[y]
    dir[y] = x
    q << y
  end
end

if dir.all?
  puts :Yes, dir.drop(2)
else
  puts :No
end


Measured memory_bytes: 32880
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
const double eps = 1e-8;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}ll n, m, s, t, r, Q, b, c,x; 
vector<ll> a,f,D;
const int MOD = 1e9 + 7;
bool ch(ll x) {
    ll sum = 0;
    rep(i, n) {
        sum += max(a[i] - x / f[i],0LL);
    }return sum <= m;
}
int main(void) {
    cin >> n >> m >> Q; a.resize(n); f.resize(m); 
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> f[i];
    rep(i, Q) {
        cin >> x;
        ll ans = INF;
        int idx1 = lower_bound(ALL(a), x) - a.begin();
        int idx2 = lower_bound(ALL(f), x) - f.begin();
        if (idx1 < n && idx2 < m) ans = min(ans, abs(x - max(a[idx1], f[idx2])));
        if (idx1 > 0 && idx2 < m) ans = min(ans, abs(x - a[idx1 - 1]) + abs(a[idx1 - 1] - f[idx2]));
        if (idx1 > 0 && idx2 < m) ans = min(ans, abs(x - f[idx2]) + abs(f[idx2] - a[idx1 - 1]));
        if (idx1 < n && idx2 > 0) ans = min(ans, abs(x - f[idx2 - 1]) + abs(f[idx2 - 1] - a[idx1]));
        if (idx1 < n && idx2 > 0) ans = min(ans, abs(x - a[idx1]) + abs(a[idx1] - f[idx2 - 1]));
        if (idx1 > 0 && idx2 > 0) ans = min(ans, abs(x - min(a[idx1 - 1], f[idx2 - 1])));
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	V cnt(4, 0);
	int n;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		if (s == "AC") cnt[0]++;
		else if (s == "WA") cnt[1]++;
		else if (s == "TLE") cnt[2]++;
		else cnt[3]++;
	}
	cout << "AC x " << cnt[0] << endl;
	cout << "WA x " << cnt[1] << endl;
	cout << "TLE x " << cnt[2] << endl;
	cout << "RE x " << cnt[3] << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=5000+19;
const int M=200+19;
const int oo=(1<<30)-1;

ll s[N][N],dis[N],res;
int B[N][M];
int n,m;

void Plus(int u,int d,int l,int r,int v){
	s[u][l]+=v;
	s[u][r+1]-=v;
	s[d+1][l]-=v;
	s[d+1][r+1]+=v;
}
void Work(int x){
	static int stk[N],pre[N],suf[N];
	B[0][x]=B[n+1][x]=oo;
	stk[*stk=1]=0;
	for (int i=1;i<=n;i++){
		while (B[i][x]>B[stk[*stk]][x]) (*stk)--;
		pre[i]=stk[*stk];
		stk[++*stk]=i;
	}
	stk[*stk=1]=n+1;
	for (int i=n;i>=1;i--){
		while (B[i][x]>B[stk[*stk]][x]) (*stk)--;
		suf[i]=stk[*stk];
		stk[++*stk]=i;
	}
	For(i,1,n+1){
		Plus(pre[i]+1,i,i,suf[i]-1,B[i][x]);
	}
}

int main(){
	n=IN(),m=IN();
	For(i,2,n+1) dis[i]=dis[i-1]+IN();
	For(i,1,n+1){
		For(j,1,m+1) B[i][j]=IN();
	}
	For(i,1,m+1) Work(i);
	For(i,1,n+1)
		For(j,1,n+1){
			s[i][j]=s[i][j-1]+s[i-1][j]-s[i-1][j-1]+s[i][j];
			if (i<=j) res=max(res,s[i][j]-(dis[j]-dis[i]));
		}
	cout<<res<<endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	vi a(5);
	ll ans;
	f(i, 0, 4) {
		cin >> a[i];
		if (a[i] == 0)
			ans = i;
	}
	cout << ans + 1 << endl;
	return 0;
}































Measured memory_bytes: 3648
#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 n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n)
    {
        cin >> a[i];
        a[i]--;
    }
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int ans = 0;
    rep(i, n)
    {
        ans += b[a[i]];
        if (i > 0 && a[i] == a[i - 1] + 1)
            ans += c[a[i - 1]];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main (void) {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    for ( int i=0; i<A; i++ )
        cin >> p.at(i);
    for ( int i=0; i<B; i++ )
        cin >> q.at(i);
    for ( int i=0; i<C; i++ )
        cin >> r.at(i);

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());

    vector<int> candidate = r;
    for ( int i=0; i<X; i++ )
        candidate.push_back(p.at(i));
    for ( int i=0; i<Y; i++ )
        candidate.push_back(q.at(i));

    sort(candidate.begin(), candidate.end(), greater<int>());

    int n = X + Y;
    long long ans = 0;
    for ( int i=0; i<n; i++ )
        ans += candidate.at(i);

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


Measured memory_bytes: 2936
#include<stdio.h>
int main (void){
	long long n,a,m,M,c,b,i;
	c = 0;
	m = 100000000;
	M = -100000000;
	scanf("%lld",&n);
	
	for( i=1; i<=n; i++ ){
		scanf("%lld",&a);
		if(a>M){
			M = a;
		}
		if(a < m){
			m = a;
		}
		c = c + a;
	}
	printf("%lld %lld %lld\n",m,M,c);
	
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> sc(m);
  for(auto&& e: sc) 
  {
    cin>>e.first>>e.second;
  }
  int i;
  if(n==3) i=100;
  else if(n==2) i=10;
  else i=0;
  for (; i < 1000; ++i)
  {
    string tmp=to_string(i);
    bool flag=true;
    for(const auto& e: sc) 
    {
      if(tmp[e.first-1]!='0'+e.second) flag=false;
    }
    if(flag)
    {
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
}

Measured memory_bytes: 256
using System;

namespace okayama_096
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');　//二つ以上のすぺーすくぎりを使う
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if (a == b)
                Console.WriteLine(a);
            else if (a < b)
                Console.WriteLine(a);
            else
                Console.WriteLine(a - 1);
            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
cnt = 0
n = int(raw_input())
A = [int(raw_input()) for _ in range(n)]
G = [1] if n < 5 else [1, 4]
while G[-1]*3+1 <= n/5: G.append(G[-1]*3+1)
G.reverse()

def insersionSort(g):
	global cnt
	for i in range(g, n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v

def shellSort():
	for g in G:
		insersionSort(g)

shellSort()
print len(G)
print " ".join(map(str, G))
print cnt
print "\n".join(map(str, A))

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

int main(){
    string s;
    cin >> s;
    string t;
    for (int i=0; i<s.size(); i++) {
        if (i%2==0) {
            t.push_back(s[i]);
        }
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

const ll MAX = 5123456;
const ll MOD = 1e9 + 7;
vector<ll> fac(MAX);
vector<ll> finv(MAX);
vector<ll> inv(MAX);

// COMinit()を忘れないように！
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(ll 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;
  }
}

ll nCr(ll n, ll r){
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  COMinit();
  for(int i = 1; i <= K; i++){
    cout << nCr(N-K+1, i)*nCr(K-1, i-1)%MOD << endl;
  }
}

Measured memory_bytes: 120320
import sys
from functools import reduce
from fractions import gcd

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

N, X = map(int, input().split())
x = list(map(int, input().split()))
d = [abs(i - X) for i in x]
print(reduce(lambda i, j: gcd(i, j), d))


Measured memory_bytes: 88172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  cout << n*n*n << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // LOCAL

    string n;   cin >> n;

    if(n.back() == '3')
    {
        puts("bon");
    }

    else if(n.back() == '0' || n.back() == '1' || n.back() == '6' || n.back() == '8')
    {
        puts("pon");
    }

    else
    {
        puts("hon");
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	vi cnt(1e6 + 7);
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		cnt[t]++;
	}	
	int ans = 0;
	for(int i = 1; i <= 1e6; i++) {
		if(cnt[i] == 1) ans++;
		if(cnt[i]) for(int j = i; j <= 1e6; j += i) cnt[j] = 0;
	}
	cout << ans << endl;

}





Measured memory_bytes: 7140
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,p[10],a,b,ans;
vector<int> v[10];
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>b;
            v[i].push_back(b-1);
        }
    }
    
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    for(int i=0;i<(1<<n);i++){
        bool ok=1;
        for(int j=0;j<m;j++){
            int tmp=0;
            for(auto x:v[j]){
                if((i>>x)&1)tmp++;
            }
            if(tmp%2!=p[j])ok=0;
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main(){
    int n,m;

    cin >> n >> m;

    vector<pair<int ,int>> s;

    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        s.emplace_back(a-1,b);
    }

    bool ans = false;

    //for(auto &x:s)cout << x.first << " " <<x.second << endl;

    for(int i = 0;i<1000;i++){
        string str =to_string(i);
        if(str.length()==n){
            ans = true;
            for(auto& x:s){
                if(str[x.first]-'0' != x.second)ans = false;
            }
        }
        if(ans){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	string s;cin>>s;
	ll c=1;
	vll v;
	rep(i,1,n){
		if(s[i]==s[i-1])c++;
		else v.pb(c),c=1;
	}
	v.pb(c);
	// teln(v,sz(v));
	cout<<sz(v);
	
	
	
	
	return 0;
}



Measured memory_bytes: 1480
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
struct Node {
	int par;
	vector<int> child;
};
Node T[20];
int N;
int cost[20][20];
bool vst[20];
int cSum;
void makeTree(int v,int p) {
	vst[v]=true;
	T[v].par=p;
	for(int i=0;i<N;i++) {
		if(cost[v][i]!=-1&&!vst[i]) {
			T[v].child.push_back(i);
			makeTree(i,v);
		}
	}
}
void dfs(int v,int c) {
	vst[v]=true;
	if(T[v].child.size()==0) {
		return;
	}
	for(int i=0;i<T[v].child.size();i++) {
		if(!vst[T[v].child[i]]) {
			dfs(T[v].child[i],cost[v][T[v].child[i]]);
		}
	}
	cSum+=c*2;
}
int bomb() {
	cSum=0;
	int pNode=0;
	while(~pNode) {
		dfs(pNode,0);
		if(~T[pNode].par)cSum+=cost[pNode][T[pNode].par];
		pNode=T[pNode].par;
	}
	return cSum;
}
int main() {
	while(scanf("%d",&N),N) {
		memset(cost,-1,sizeof(cost));
		int a,b,t;
		for(int i=0;i<N-1;i++) {
			scanf("%d %d %d",&a,&b,&t);
			cost[a-1][b-1]=cost[b-1][a-1]=t;
		}
		int res=1<<30;
		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++)T[j].child.clear();
			memset(vst,0,sizeof(vst));
			makeTree(i,-1);
			memset(vst,0,sizeof(vst));
			res=min(res,bomb());
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 1052
/*input
aaa
5
*/

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

int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll odd = 0;
    ll even = 0;
    int len = s.length();
    bool is_changed = false;
    // odd
    rep(i, len-1) {
        if (s[i] == s[i+1] && !is_changed) {
            odd++;
            is_changed  = true;
        }
        else {
            is_changed = false;
        }
    }
    // even
    if (s[len-1] == s[0] && !is_changed) {
        even++;
        is_changed = true;
    }
    else {
        is_changed = false;
    }
    rep(i, len-1) {
        if (s[i] == s[i+1] && !is_changed) {
            even++;
            is_changed  = true;
        }
        else {
            is_changed = false;
        }
    }
    if (is_changed) {
        cout << (k+1)/2*odd+k/2*even << endl;
    }
    else {
        cout << odd+(k-1)*even << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}
template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

struct edge{
    int dest;
    ll fee;
    ll cost;
};

int N, M, S;
vector<vector<ll>> dijkstra(vector<vector<edge>> &vec){
    priority_queue<tuple<ll,int,int>, vector<tuple<ll,int,int>>, greater<tuple<ll,int,int>>> que;
    que.push(make_tuple(0,min(S,2500),0));
    vector<vector<ll>> dist((int)vec.size(),vector<ll>(2501,MOD*MOD));
    
    while((int)que.size()){
        //cout<<que.size()<<endl;
        ll cost=get<0>(que.top());
        int silver=get<1>(que.top());
        int x=get<2>(que.top());
        que.pop();
        if(dist[x][silver]>cost){
            dist[x][silver]=cost;
        }else{
            continue;
        }

        for(auto nx:vec[x]){
            if(silver-nx.fee>=0){
                que.push(make_tuple(cost+nx.cost,min(2500LL,silver-nx.fee),nx.dest));
            }

        }
    }
    return dist;
}

int main(){
    
    cin >> N >> M >> S;
    vector<vector<edge>> vec(N,vector<edge>(0));
    for(int i=0; i<M; i++){
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--;v--;
        vec[u].push_back({v,a,b});
        vec[v].push_back({u,a,b});
    }

    for(int i=0; i<N; i++){
        int c,d;
        cin >> c >> d;
        vec[i].push_back({i,-c,d});
    }

    vector<vector<ll>> dist=dijkstra(vec);
    //cout_mat(dist);
    for(int i=1; i<N; i++){
        ll ans=MOD*MOD;
        for(auto x:dist[i]){
            ans=min(x,ans);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 8460
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def c(n,d):
    return n+d*N

def dfs(s,n):
    global visited
    visited[s][n] = True
    for t in lines[s]:
        if not visited[t][n]:
            dfs(t,n)


while True:
    N = inp()
    if N == 0:
        break
    else:
        days = 30
        nds = [[False]*days for _ in range(N)]
        for n in range(N):
            tmpl = inpl()
            for i in range(1,tmpl[0]+1):
                nds[n][tmpl[i]-1] = True

        lines = defaultdict(set)
        cnt = 0
        for n in range(N):
            for d1 in range(days):
                for d2 in range(d1,days):
                    if nds[n][d1] and nds[n][d2]:
                        lines[c(n,d1)].add(c(n,d2))

        for d in range(days):
            for n1 in range(N):
                for n2 in range(n1,N):
                    if nds[n1][d] and nds[n2][d]:
                        lines[c(n1,d)].add(c(n2,d))
                        lines[c(n2,d)].add(c(n1,d))

        visited = [[False]*N for _ in range(c(N,days))]
        for n in range(N):
            for d in range(days):
                if nds[n][d]:
                    dfs(c(n,d),n)

        #print(visited)

        for b in range(N*days):
            for n in range(N):
                #print(b,n,visited[b][n])
                if visited[b][n]:
                    continue
                else:
                    break
            else:
                print(b//N+1)
                break
        else:
            print(-1)



Measured memory_bytes: 14572
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, k] = input[0].split(" ").map((x: string): number => +x);

interface Point {
	x: number;
	y: number;
	c: string;
}

const p: Array<Point> = [];
for (let i = 0; i < n; i++) {
	const [_x, _y, c] = input[i + 1].split(" ");
	p.push({x: +_x, y: +_y, c});
}

interface Rect {
	x: number;
	y: number;
}

const areas: Array<Rect> = [];
for (let {x, y, c} of p) {
	if (c === "W") x += k;
	x = x % (2 * k);
	y = y % (2 * k);
	for (let i = 0; i < 4; i++) {
		for (let ii = 0; ii < 4; ii++) {
			if ((i + ii) % 2 !== 0) continue;
			areas.push({x: x + ii * k, y: y + i * k});
		}
	}
}
const rsw: Array<Array<number>> = []; // ruisekiwa
for (let i = 0; i < 4 * k; i++) {
	rsw.push(new Array(4 * k).fill(0));
}

for (let {x, y} of areas) {
	let r = x + k; // right
	let b = y + k; // bottom
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	if (y < 4 * k && x < 4 * k) rsw[y][x] += 1;
	if (y < 4 * k && r < 4 * k) rsw[y][r] -= 1;
	if (b < 4 * k && x < 4 * k) rsw[b][x] -= 1;
	if (b < 4 * k && r < 4 * k) rsw[b][r] += 1;
}

for (let y = 0; y < 4 * k; y++) {
	for (let x = 1; x < 4 * k; x++) {
		rsw[y][x] += rsw[y][x - 1];
	}
}

for (let y = 1; y < 4 * k; y++) {
	for (let x = 0; x < 4 * k; x++) {
		rsw[y][x] += rsw[y - 1][x];
	}
}

let result = 0;

for (let y = 2 * k; y < 4 * k; y++) {
	for (let x = 2 * k; x < 4 * k; x++) {
		if (rsw[y][x] > result) result = rsw[y][x];
	}
}

console.log(result);

Measured memory_bytes: 213696
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}

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

int main(){
    int H,W;
    char S[20][20];
    int d[20][20];
    cin >> H>>W;
    rep(i,H)rep(j,W){
        cin >> S[i][j];
        //if(S[i][j] == '.')sx= i,sy = j;
        //d[i][j] = -1;
    }
    vector<int> v;
    rep(i,H)rep(j,W){
        if(S[i][j] == '.'){

    rep(i,H)rep(j,W)d[i][j] = -1;
    int sx= i,sy = j;
    queue<pint> que;
    que.push(pint(sx,sy));
    d[sx][sy] =0;
    int a=0;
    while(que.size()){
        pint p = que.front();
        que.pop();
        rep(i,4){
            int nx = p.first+dx[i];
            int ny = p.second+dy[i];
            if(nx >=0 && nx < H && ny >=0 && ny < W && 
                S[nx][ny]!='#' && d[nx][ny] == -1){
                que.push(pint(nx,ny));
                d[nx][ny] = d[p.first][p.second] +1;
                if(a < d[nx][ny])a = d[nx][ny];
            }
        }
    }
    v.push_back(a);
    }
    }
    RSORT(v);
    cout << v[0];

}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}

int dp[3001][3001];

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    string s,t;
    cin>>s>>t;

    int n = s.size() , m = t.size();


    for(int i=1; i<=n; i++){

        for(int j=1; j<=m; j++){

            dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            if(s[i-1] == t[j-1]) dp[i][j] = max(dp[i-1][j-1] + 1 ,dp[i][j]);
        }
    }

    string ans;
    //acout<<dp[n][m]<<endl;
    for(int i=n,j=m; i && j ; ){

        if(s[i-1] == t[j-1]){
            ans += s[i-1];
            i--;
            j--;
        }
        else if(dp[i][j] == dp[i-1][j])i--;
        else if(dp[i][j] == dp[i][j-1])j--;
    }

    reverse(atoz(ans));
    cout<<ans;

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 1e5+5;
const long long int MINN = 2e6 + 5;
const long long int inf = 1e7;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 5e5+5;
const int MAXN = 105;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
int power(int x,int y){
    int res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}

int main(){
    FAST    
    int n;
    cin>>n;
    int x = ceil((1.*n)/(1000.0));
    cout<< x*1000 - n;
    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
int n,cnt[111],m=111,M;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;cin>>a;
		cnt[a]++;
		if(m>a)m=a;
		if(M<a)M=a;
	}
	bool flag=M%2&&cnt[m]==2||M%2==0&&cnt[m]==1;
	for(int i=m+1;i<=M;i++)
	{
		flag&=cnt[i]>=2;
	}
	flag&=m*2>=M;
	cout<<(flag?"P":"Imp")<<"ossible"<<endl;
}

Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
l = sorted([int(input()) for i in range(N)],reverse=True)
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
ans = float('inf')
for i in range(4**N):
    q = Base_10_to_n(i,4)
    q = str('0'*(N-len(q))+q)
    a = []
    b = []
    c = []
    for j in range(N):
        if q[j] == '1':
            a.append(l[j])
        if q[j] == '2':
            b.append(l[j])
        if q[j] == '3':
            c.append(l[j])
    cost = 0
    if a and b and c:
        cost += 10*(len(a)+len(b)+len(c)-3)
        cost += abs(A-sum(a)) + abs(B-sum(b))+ abs(C-sum(c))
        ans = min(ans,cost)
print(ans)
        
        
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAXN 4000005
using namespace std;

int n,a[MAXN],b[MAXN],ok,js = 0,maxl = 0;
int vis[MAXN],prime[MAXN],tot,judge[MAXN];

void init(){
	memset(vis , -1 , sizeof(vis));
	tot = 0;
	for(int i = 2 ; i <= 2000000 ; i++){
		if(vis[i] == (-1)){tot++;prime[tot] = i;}
		for(int j = 1 ; j <= tot && prime[j] * i <= 2000000 ; j++){
			vis[prime[j] * i] = 1;
			if(i % prime[j] == 0)break;
		}
	}

}

int gcd(int a , int b){
	if(b == 0)return a;
	return gcd(b , a % b);
}

int cmp(int x , int y){
	return x < y;
}
inline int read()
{
	char c = getchar(); int res = 0;
	while(c < '0' || c >'9') c = getchar();
	while(c >= '0' && c <= '9')
	{
		res = res * 10 + c - '0';
		c = getchar();
	}
	return res;
}

int main(){
	init();
	ok = 0;
	n = read();
	for(int i = 1 ; i <= n ; i++){
		a[i] = read();	
		maxl = max(maxl , a[i]);
		b[i] = a[i];
	}
	while(prime[js] * prime[js] <= maxl)js++;
	int cnt;
	for(int j = 1 ; j <= js ; j++){
		cnt = 0;
		for(int i = 1 ; i <= n ; i++){
			if(a[i] % prime[j] == 0){
				cnt++;
				while(a[i] % prime[j] == 0)a[i] /= prime[j];
			}	
		}	
		if(cnt > 1){
			ok = 1;
			break;
		}
	}
	sort(a + 1 , a + 1 + n , cmp);
	for(int i = 1 ; i < n ; i++){
		if(a[i] == 1)continue;
		if(a[i] == a[i + 1]){
			ok = 1;
			break;
		}
	}
	for(int i = 1 ; i <= n ; i++){
		a[i] = b[i];
	}
	if(ok == 1){
		ok = 0;
		int zz = gcd(a[1] , a[2]);
		for(int i = 1 ; i <= n ; i++)zz = gcd(zz , a[i]);
		if(zz == 1)cout<<"setwise coprime"<<endl;
		else cout<<"not coprime"<<endl;
	}
	else{
		cout<<"pairwise coprime"<<endl;
		exit(0);
	}
}


Measured memory_bytes: 27616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int h,n;cin>>h>>n;
    int a[n];
    int sum = 0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)cY
    else cN;
}

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

using namespace std;
bool au[1000005],bu[1000005];
long long a,b;

int main()
{
    cin >> a >> b;
    long long sa = sqrt(a),sb = sqrt(b);
    vector<long long> va1,vb1;
    vector<long long> va2,vb2;
    va2.push_back(a);vb2.push_back(b);
    for(int i=2;i<=sa;++i)
    {
        if(au[i]) continue;
        if(a%i==0)va1.push_back(i);
        for(int j=i;j<=sa;j+=i)
            au[j] = true;
        while(a%i==0) a/=i;
    }

    for(int i=2;i<=sb;++i)
    {
        if(bu[i]) continue;
        if(b%i==0)vb1.push_back(i);
        for(int j=i;j<=sb;j+=i)
            bu[j] = true;
        while(b%i==0) b/=i;
    }
    if(a!=1)va1.push_back(a);
    if(b!=1)vb1.push_back(b);

    int i=0,j=0;
    int cnt = 1;

    while(i<va1.size()&&j<vb1.size()){
        if(va1[i]<vb1[j])++i;
        else if(va1[i]>vb1[j])++j;
        else {
            ++i;++j;++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>

int main()
{
    int a[3001] = {};
    int N, sum = 0, i;

    scanf("%d", &N);

    for(i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i]-1;
    }

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

  	return 0;

}


Measured memory_bytes: 128
H,W=list(map(int,input().split()))
inf=float("inf")
import numpy as np
mem=np.full((H,W),inf)
l=[list(input()) for i in range(H)]
for i in range(H):
   for j in range(W):
      if l[i][j]=="#":
         mem[i,j]=0
for i in range(W-1):
   mem[:,i+1]=np.minimum(mem[:,i]+1,mem[:,i+1])
for i in reversed(range(1,W)):
   mem[:,i-1]=np.minimum(mem[:,i-1],mem[:,i]+1)
for i in range(H-1):
   mem[i+1,:]=np.minimum(mem[i+1,:],mem[i,:]+1)
for i in reversed(range(1,H)):
   mem[i-1,:]=np.minimum(mem[i-1,:],mem[i,:]+1)
print(int(np.max(mem)))

Measured memory_bytes: 42176
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<cmath>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	int n, d;
	cin >> n >> d;
	int ans = 0;
	d *= 2;
	d++;
	if (n % d == 0) {
		ans = n / d;
	}
	else {
		ans = n / d + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

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

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pllint a, pllint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	llint n;
	cin >> n;
	n--;
	llint ans = (llint)n / 11 * 2;
	n %= (llint)11;
	if (n <= 5)cout << ans + 1 << endl;
	else cout << ans + 2 << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def main():
    a,b,c = MII()
    if a==b:
        print(c)
    elif a==c:
        print(b)
    else:
        print(a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <string.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<char, int> Pc;

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

// Self settings
// clang-format off
#define MAX_N 3000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on
char s[MAX_N + 1], t[MAX_N + 1];
int dp[MAX_N + 1][MAX_N + 1];

void solve()
{
  int sl = strlen(s), tl = strlen(t);
  REP(i, sl + 1) REP(j, tl + 1) dp[i][j] = 0;
  for (int i = 0; i < sl; i++) {
    for (int j = 0; j < tl; j++) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      }
      else {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
  }
  if (dp[sl][tl] == 0) {
    cout << " " << endl;
  }
  else {
    string ans = "";
    int cur = dp[sl][tl];
    int i = sl, j = tl;
    while (i > 0 && j > 0) {
      if (s[i - 1] == t[j - 1]) {
        ans += s[i - 1];
        cur--;
        i--, j--;
      }
      else if (i - 1 >= 0 && dp[i - 1][j] == cur) {
        i--;
      }
      else if (j - 1 >= 0 && dp[i][j - 1] == cur) {
        j--;
      }
      else {
        i--;
      }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
}

int main(void)
{
  cin >> s >> t;
  solve();
  return 0;
}


Measured memory_bytes: 35456
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        String S;
        S = sc.next();
        solve(S);
    }

    static void solve(String S){
        if(S.equals("ABC")) System.out.println("ARC");
        else System.out.println("ABC");
    }

    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 32508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> a(2, vector<ll>(1e5, 0));
  REP(i, n) {
    ll x;
    cin >> x;
    x--;
    a[i % 2][x]++;
  }
  vector<vector<P>> p(2);
  REP(i, 1e5) {
    REP(j, 2) { p[j].push_back({i, a[j][i]}); }
  }
  REP(i, 2) {
    sort(ALL(p[i]), [](P x, P y) { return x.second > y.second; });
  }
  ll ans = 1e18;
  REP(i, 2) REP(j, 2) {
    ll x = p[0][i].first, y = p[1][j].first;
    if (x == y) {
      continue;
    }
    ll t = (n / 2 - a[0][x]) + (n / 2 - a[1][y]);
    ans = min(ans, t);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6376