akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
using namespace std;

int main() {
	string O, E;
	cin >> O >> E;
	string ans = "";
	for (int i = 0; i < E.size(); i++) {
		ans += O[i];
		ans += E[i];
	}
	if (O.size() > E.size())
		ans += O.back();
	cout << ans << endl;
}

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

using namespace std;
int main() {
    int n, a, b;
    cin >> n >> a >> b;

    if (n * a < b) {
        cout << n * a;
    }
    else {
        cout << b;
    }
    
}

Measured memory_bytes: 256
n = int(input())
a_ = list(map(int,input().split()))
adic = {}
for i in range(n):
    a = a_[i]
    if a in adic.keys():
        adic[a] += 1
    else:
        adic[a] = 1
ans = 0
for i in adic.values():
    if i >= 2:
        ans += i*(i-1)//2
moto = ans
for i in range(n):
    a = a_[i]
    b = adic[a]
    if b >= 2:
        ans -= b*(b-1)//2
        ans += (b-1)*(b-2)//2
    print(ans)
    ans = moto

Measured memory_bytes: 25716
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    s, t = (line.strip() for line in sys.stdin.readlines())
    if sorted(s) < sorted(t, reverse=True):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<utility>
#include<climits>
#include<cmath>
using namespace std;

int main()
{
	long a, b;
	long c, d, e;
	long gcd, lcm;


	while (cin >> a >> b)
	{	
		c = a, d = b;
		while (d != 0)
		{
			e = c % d;
			c = d; d = e;
		}

		gcd = c;
		lcm = a * b /gcd;

		cout << gcd << " " << lcm << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/10 20:57:40
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5, MOD = 998244353;

int qpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;   
}
int fac[N], inv[N];

void run() {
    int n, m, k;
    cin >> n >> m >> k;
    fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[n] = qpow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
    int ans = 0;
    for (int t = n - k; t <= n; t++) {
        //x_1+x_2+..x_t = n
        int res = 1ll * m * qpow(m - 1, t - 1) % MOD;
        res = 1ll * res * fac[n - 1] % MOD * inv[t - 1] % MOD * inv[n - t] % MOD;
        ans = (ans + res) % MOD;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 5172
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);

    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    vector<int> first = graph[0];

    vector<int> second;
    bool possible = false;
    REP(i, first.size()) {
        REP(j, graph[first[i]].size()) {
            if (graph[first[i]][j] == N - 1) {
                possible = true;
            }
        }
    }
    YESNO(possible, "POSSIBLE", "IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 12400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

const int maxn = 2e5 + 10;

struct SGT
{
	int t[maxn << 2];

	void upt(int o, int l, int r, int x, int v)
	{
		if(l == r) { t[o] = min(t[o], v); return ; } 
		int mid = (l + r) >> 1;
		if(x <= mid) upt(o << 1, l, mid, x, v);
		else upt(o << 1 | 1, mid + 1, r, x, v);
		t[o] = min(t[o << 1 | 1], t[o << 1]);
	}

	int que(int o, int l, int r, int x, int y)
	{
		if(x <= l && r <= y) return t[o]; 
		int mid = (l + r) >> 1, ret = 0x3f3f3f3f;
		if(x <= mid) ret = que(o << 1, l, mid, x, y);
		if(y > mid) ret = min(ret, que(o << 1 | 1, mid + 1, r, x, y));
		return ret;
	}
}S1, S2;

int b[maxn], sum0[maxn], sum1[maxn];
pair<int, int> Q[maxn];

int main()
{
	memset(S1.t, 0x3f, sizeof(S1.t));
	memset(S2.t, 0x3f, sizeof(S2.t));

	int n = read();
	for(int i = 1; i <= n; ++i) b[i] = read();
	for(int i = 1; i <= n; ++i) sum0[i] = sum0[i - 1] + (b[i] == 0), sum1[i] = sum1[i - 1] + (b[i] == 1);

	int m = read();
	for(int i = 1; i <= m; ++i)
	{
		int x = read(), y = read();
		Q[i] = make_pair(x, y);
	}
	sort(Q + 1, Q + m + 1);

	sum0[n + 1] = sum0[n];
	Q[m + 1] = make_pair(n + 1, n + 1); ++m;
	S1.upt(1, 0, n, 0, 0);
	S2.upt(1, 0, n, 0, 0);
	for(int i = 1; i <= m; ++i)
	{
		int tmp = S2.que(1, 0, n, 0, Q[i].first - 1);
		//cout << '*' << tmp << ' ' << Q[i].first - 1 << endl;
		tmp = tmp + sum1[Q[i].first - 1] + sum0[Q[i].second] - sum0[Q[i].first - 1];
		if(i == m) { printf("%d\n", tmp); return 0; }
		int tmp1 = S1.que(1, 0, n, Q[i].first, Q[i].second);
		tmp1 = tmp1 + sum0[Q[i].second];
		int now = min(tmp, tmp1);
		//cout << Q[i].second << ' ' << now - sum1[Q[i].second] << endl;
		S1.upt(1, 0, n, Q[i].second, now - sum0[Q[i].second]);
		S2.upt(1, 0, n, Q[i].second, now - sum1[Q[i].second]);
	}

	return 0;
}


Measured memory_bytes: 10496
def c_pushpush():
    # Aの奇数番目の要素と偶数番目の要素をそれぞれ一塊にすることは変わらない。
    # ただし、どちらを左右にするかは N の偶奇によって変わる
    N = int(input())
    A = [int(i) for i in input().split()]
    return ' '.join(map(str, A[int(N % 2 == 0)::2][::-1] + A[int(not N % 2 == 0)::2]))

print(c_pushpush())

Measured memory_bytes: 28100
#include <stdio.h>

int main(void)
{
    int a, b, c, tmp, cnt;

    scanf("%d %d %d", &a, &b, &c);
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    cnt = 0;

    for (; a<=b; a++) {
        if (c % a == 0) {
            cnt++;
        }
    }

    printf("%d\n", cnt);
}


Measured memory_bytes: 2108
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    int N;
    cin >> N;

    vector<ll> as(N);
    bool has_zero = false;
    for (int i = 0; i < N; i++) {
        cin >> as[i];
        if (as[i] == 0) {
            has_zero = true;
        }
    }

    if (has_zero) {
        cout << 0 << endl;
        return 0;
    }

    bool ok = true;
    ll acc = 1;
    for (int i = 0; i < N; i++) {
        if (acc > LONG_LONG_MAX / as[i]) {
            ok = false;
            break;
        }
        ll x = acc * as[i];
        if (x > 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL) {
            ok = false;
            break;
        }
        acc = x;
    }

    if (ok) {
        cout << acc << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 4028
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif
    int n;
    LL a,b;
    scanf("%d",&n);
    cin>>a;
    for(int i = 1 ; i < n ; i++){
        cin>>b;
        a = a/gcd(a,b)*b;
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i, j, hill[10], temp;
	for(i = 0; i < 10; i++)
	{
		scanf("%d", &hill[i]);
	}
	
	for(i = 0; i < 3; i++)
	{
		for(j = i+1; j < 10; j++)
		{
			if(hill[i] < hill[j])
			{
				temp = hill[i];
				hill[i] = hill[j];
				hill[j] = temp;
			}
		}
	}
	
	printf("%d\n%d\n%d\n", hill[0], hill[1], hill[2]);
	
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

//printf("%d", n);
//printf("%d", sum);
//scanf("%d", &n);
//scanf("%c", &c);
//scanf("%lf", &d);

int main(int argc, char** argv){
    int N;
    char str[16384];
    scanf("%d", &N);
    scanf("%s", str);

    char* ptr = str;
    while(*ptr){
        int pch = *ptr + N;
        if(pch > 'Z'){
            pch -= 26;
        }
        printf("%c", pch);
        ptr++;
    }

    printf("\n");

    return 0;
}




Measured memory_bytes: 128
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
  
b,a=zip(*sorted(zip(b,a)))
sum=0

for i in range(n):
  sum+=a[i]
  if sum>b[i]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 47528
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t A;
  double B;
  cin >> A >> B;
  B *= 100;
  int b = round(B);
  int64_t ans = A*b;
  ans /= 100;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 13

int N,M,X;
int POW[SIZE],a[SIZE];
int b[SIZE][SIZE],c[SIZE];
int main(){
	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){
		POW[i] = POW[i-1]*2;
	}
	scanf("%d %d %d",&N,&M,&X);
	for(int i = 0; i < N; i++){
		scanf("%d",&a[i]);
		for(int k = 0; k < M; k++){
			scanf("%d",&b[i][k]);
		}
	}	
	int ans = BIG_NUM;
	bool FLG;
	for(int state = 0; state < POW[N]; state++){
		memset(c,0,sizeof(c)); 
		int sum = 0;
		for(int loop = 0; loop < N; loop++){
			if(state & POW[loop]){
				sum += a[loop];
				for(int k = 0; k < M; k++){
					c[k] += b[loop][k];
				}
			}
		} 
		FLG = true;
		for(int i = 0; i < M; i++){
			if(c[i] < X){
				FLG = false;
				break;
			}
		}
		if(FLG) ans = min(ans,sum);
	}
	if(ans == BIG_NUM) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3848
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-23 20:15:07
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 INF = 1e18;

template <typename T>
class CumulativeSum {
 public:
  CumulativeSum(const std::vector<T>& vec) : vec_(vec) { Build(); }
  T Get(int left, int right);

 private:
  std::vector<T> vec_;
  std::vector<T> sum_;
  void Build();
};

// return sum of [left, right]
template <typename T>
T CumulativeSum<T>::Get(int left, int right) {
  return sum_[right + 1] - sum_[left];
}

template <typename T>
void CumulativeSum<T>::Build() {
  sum_.assign(vec_.size() + 1, static_cast<T>(0));
  for (size_t i = 0; i < vec_.size(); ++i) {
    sum_[i + 1] = sum_[i] + vec_[i];
  }
}

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

  int n; cin >> n;
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  CumulativeSum<int64> cs(a);

  int64 ans = INF;

  for (int i = 0; i < n; ++i) {
    ans = min(ans, abs(cs.Get(0, i) - cs.Get(i + 1, n - 1)));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x) for(int i = 0;i < x;++i)
#define FOR(i,x,y) for(int i = x;i < y;++i)
#define ALL(a) a.begin(),a.end()
using ll = long long;

int n,q;
int par[12345];
int rnk[12345];
int siz;
void init(int n_)
{
    siz = n_;
    REP(i,siz)
    {
        par[i] = i;
        rnk[i] = 0;
    }
}
int parent(int x)
{
    if(x == par[x])return x;
    return par[x] = parent(par[x]);
}
void unite(int x,int y)
{
    x = parent(x);
    y = parent(y);
    if(x == y)return;
    if(rnk[x] < rnk[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if(rnk[x] == rnk[y])
        {
            rnk[x]++;
        }
    }
}
bool find(int x,int y)
{
    return parent(x) == parent(y);
}

int main()
{
    cin >> n >> q;
    init(n);
    REP(i,q)
    {
        int com,x,y;
        cin >> com >> x >> y;
        if(com == 0)
        {
            unite(x,y);
        }
        else
        {
            cout << (find(x,y) ? 1 : 0) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=1e6+10;
const int mod=1e9+7;
using namespace std;

struct Point{int x,y;};
struct segment{Point p1,p2;};
struct endpoint
{
  Point p; int id,type; 
  endpoint(){}
  endpoint(Point p,int id,int type):p(p),id(id),type(type){}
  bool operator < (const endpoint &ep)const {return p.y==ep.p.y?type<ep.type:p.y<ep.p.y;}
};
int sweep(vector<segment> v)
{
   vector<endpoint> ep;
   for(int i=0,sz=v.size();i<sz;i++)
   {
      segment &e=v[i];
      if(e.p1.x==e.p2.x)
      {
         if(e.p1.y>e.p2.y) swap(e.p1,e.p2);
         ep.pb(endpoint(e.p1,i,0));
         ep.pb(endpoint(e.p2,i,3));
      }
      else 
      {
         if(e.p1.x>e.p2.x) swap(e.p1,e.p2);
         ep.pb(endpoint(e.p1,i,1));
         ep.pb(endpoint(e.p2,i,2));
      }
   }
   sort(ep.begin(),ep.end()); 
   int ans=0; set<int> s; s.insert(inf);
   for(auto e: ep)
   {
      if(e.type==0) s.insert(e.p.x);
      else if(e.type==3) s.erase(e.p.x);
      else if(e.type==1) ans+=distance(s.lower_bound(v[e.id].p1.x),s.upper_bound(v[e.id].p2.x));
   }
 return ans;
}
int main()  
{  
     int n;  scanf("%d",&n);
     vector<segment> v; segment t;
     for(int i=1;i<=n;i++) scanf("%d%d%d%d",&t.p1.x,&t.p1.y,&t.p2.x,&t.p2.y),v.pb(t);
     printf("%d\n",sweep(v));
return 0;  
}  


Measured memory_bytes: 11940
# -*- coding: utf-8 -*-
# input
#a = int(input())
#a = input()
a, b, c, d = map(int, input().split())
#a, b, c = input().split()
o = 0
for i in range((d//a)+1):
    for j in range(((d-a*i)//b)+1):
        if (d-a*i-b*j) % c == 0:
            o += 1
# output
print(o)


Measured memory_bytes: 2940
class FUnionFind
  def initialize(n)
    @parents = (0...n).to_a
    @nodes = @parents.map{ |x| [x] }
  end

  def find(i)
    @parents[i]
  end

  def union(i,j)
    i = @parents[i]; j = @parents[j]
    return if i == j
    j,i = i,j if @nodes[i].size < @nodes[j].size
    @nodes[j].each{ |k| @parents[k] = i }
    @nodes[i].concat(@nodes[j])
    @nodes[j].clear
  end
end

N,M = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)
uf = FUnionFind.new(N)
(0...M).each{ 
  a,b = gets.split.map(&:to_i)
  uf.union(a-1, b-1)  
}

g = {}
ans = 0
P.each_with_index{ |a,i|
  k = uf.find(a-1)
  g[k] ||= {}
  g[k][a-1] = 1
}
P.each_with_index{ |a,i|
  k = uf.find(a-1)
  if g[k][i]
   ans += 1
  end
}

p ans


Measured memory_bytes: 44940
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n;
string s;

string itos(int x) {
	stringstream ss; ss << x;
	string res; ss >> res;
	return res;
}

void solve() {
	for_(i,0,n) {
		string nx;
		
		int len = size_of(s);
		int cnt = 1;
		
		for_(j,0,len) {
			if (j < len - 1 && s[j] == s[j + 1]) {
				++cnt;
			} else {
				nx += string( itos(cnt) + s[j] );
				cnt = 1;
			}
		}
		
		swap(s, nx);
	}
	
	cout << s << endl;
}

int main() {
	while (cin >> n, n) {
		cin >> s;
		solve();
	}
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int r,g,b;
    cin >>r>>g>>b;

    //cout <<fixed<<setprecision(16)<< << endl;
    //out<<ans<<endl;
    if((10*g+b)%4==0)cout << "YES" <<endl;
    else cout << "NO" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	while (N != 0) {
		vector<int>A(86401, 0);
		int ans = 0, num = 0;
		char a, b, c, d, e, f, g, h;
		for (int i = 0; i < N; i++) {
			cin >> a >> b >> c >> d >> e >> f >> g >> h;
			int H = (a - '0') * 10 + (b - '0'), M = (d - '0') * 10 + (e - '0'), S = (g - '0') * 10 + (h - '0');
			A.at(H * 3600 + M * 60 + S) += 1;
			cin >> a >> b >> c >> d >> e >> f >> g >> h;
			H = (a - '0') * 10 + (b - '0'), M = (d - '0') * 10 + (e - '0'), S = (g - '0') * 10 + (h - '0');
			A.at(H * 3600 + M * 60 + S) -= 1;
		}
		for (int i = 0; i < 86401; i++) {
			num += A.at(i);
			ans = max(ans, num);
		}
		cout << ans << endl;
		cin >> N;
	}
}


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

using namespace std;

struct box
{
	int a;
	int b;
};

int main()
{
	int n;
	long long k;
	cin >> n >> k;
	
	vector<box> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i].a >> x[i].b;
	}
	
	sort(x.begin(), x.end(), [](const box& n, const box& m) {return n.a < m.a;});
	
	int i = 0;
	while(k > 0)
	{
		k -= x[i++].b;
	}
	
	cout << x[i - 1].a << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(pair<int,int> &p:A)
    cin>>p.second>>p.first;
  sort(A.begin(),A.end());
  int t=0;
  for(pair<int,int> &p:A){
    t+=p.second;
    if(t>p.first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 6404
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
const int P = 1e9 + 7;

int x[N], y[N], b[N], n, m, tot;
pair<int, int> a[N];

int seg[N];

void add(int x, int t)
{
	for (; x <= tot; x += x & -x)
		(seg[x] += t) %= P;
}

int query(int x)
{
	int res = 0;
	for (; x; x -= x & -x)
		(res += seg[x]) %= P;
	return res;
}

int main()
{
	n = read();
	m = read();
	
	for (int i = 1; i <= n; ++i) x[i] = read();
	for (int i = 1; i <= m; ++i) y[i] = read();
	
	for (int i = 1; i <= n; ++i)
	{
		int nxt = upper_bound(y + 1, y + m + 1, x[i]) - y;
		int pre = nxt - 1;
		
		if (pre <= 0 || nxt > m) continue;

		nxt = y[nxt] - x[i];
		pre = x[i] - y[pre];
		
		a[++tot] = make_pair(pre, nxt);
		b[tot] = nxt;
	}
	
	n = tot;
	
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	tot = unique(b + 1, b + n + 1) - b;
	
	add(1, 1);
	
	for (int i = 1, j = 1; i <= n; i = j)
	{
		while (j <= n && a[i].first == a[j].first) ++j;
		
		for (int k = j - 1; k >= i; --k)
		{
			//printf("%d %d\n", a[k].first, a[k].second);
			a[k].second = lower_bound(b + 1, b + tot, a[k].second) - b;
			//printf("%d\n", a[k].second);
			if (k < j - 1 && a[k].second == a[k + 1].second) continue;
			add(a[k].second + 1, query(a[k].second));
		}
	}
	
	printf("%d\n", query(tot));
	
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=300005;
char s[MAX_N];
int pre[MAX_N];
int rev[MAX_N];
int n;
int main()
{
	cin>>n;
	scanf("%s",s+1);
	For(i,1,n)
	{
		pre[i]=pre[i-1]+(s[i]=='E');
	}
	per(i,n,1)
	{
		rev[i]=rev[i+1]+(s[i]=='W');
	}
	int ans=INF;
	For(i,1,n)
	{
		ans=min(ans,n-pre[i-1]-rev[i+1]-1);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int n,m,t,ans,a[2004];
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(a[i]+a[j]>a[k]) ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
 
using namespace std;
 
priority_queue<pair<int, int> > q;
int n, m, d[1000001], a, b;
 
main(){
  cin >> n >> m;
  for(int i=0;i<n;i++) q.push(make_pair(0, -n));
  for(int i=0;i<m;i++){
    cin >> a >> b;
    d[a] += b;
    q.push(make_pair(d[a], -a));
    while(1){
      pair<int, int> p = q.top();
      if(p.first == d[-p.second]){
        cout << -p.second << ' ' << p.first << endl;
        break;
      }
      q.pop();
    }
  }
}

Measured memory_bytes: 22316
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){

   vector<string> ans;
   string deck;

   cin >> deck;

   for(;deck != "-";){

      int m, h;

      cin >> m;

      for(int i = 0; i < m; i++){
         cin >> h;
         string d1, d2;
         d1 = deck.substr(0, h);
         d2 = deck.substr(h, deck.length() - h);
         deck = d2 + d1;
      }

      ans.push_back(deck);

      cin >> deck;
   }

   for(int i = 0; i < ans.size(); i++){
      cout << ans[i] << endl;
   }

   return 0;
}


Measured memory_bytes: 3208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            int n = ReadAndParseInt();
            string[] w = new string[n];
            for(int i=0;i<n;++i)
            {
                w[i] = Console.ReadLine();
            }

            bool success = true;
            var hashset = new HashSet<string>();
            hashset.Add(w[0]);
            for(int i=1;i<w.Length;++i)
            {
                string preb = w[i-1];
                string next = w[i];
                if(hashset.Contains(next))
                {
                    success = false;
                    break;
                }
                if(preb[preb.Length-1] != next[0])
                {
                    success = false;
                    break;
                }
                hashset.Add(next);
            }
            if( success)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}


signed main() {
	int k,t=0;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int ii = 1; ii <= k; ii++) {
				t += gcd(gcd(i, j), gcd(j, ii));
			}
		}
	}
	cout << t << endl;
}





Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    long long N, A, B, d;

    cin >> N >> A >> B;

    if(abs(A-B) % 2 == 0){
        cout << (B-A) / 2 << endl;
    }

    else{
        d = min(A-1, N-B);

        cout << d+1+(B-A-1)/2 << endl;
    }

    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;

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

    if (N /100 == 7) cout << "Yes" << endl;
    else if ((N % 100) / 10 == 7) cout << "Yes" << endl;
    else if (N % 10 == 7) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int n;
    cin>>n;
    int ans=(n%1000==0)?0:(1000-n%1000);


    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
//    cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = (int)1e9 + 7;
const ll linf = 1e18;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, a[N], pr[N], f[N];

void update (int pos, int val){
    for (; pos <= N; pos |= pos + 1) f[pos] += val;
}

int get (int pos){
    int sum = 0;
    for (; pos >= 0; pos &= pos + 1, pos--) sum += f[pos];
    return sum;
}

int main (){
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i), update(a[i], 1);
    int ans = 0;
    for (int k = 1; k <= 1e5; ++k){
        int num1 = get(k - 1), num2 = get(1e5) - get(k - 1);
        if (num1 == num2) ans++;
    }
    return !printf ("%d\n", ans);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i;
  long h[100005];
  char str[2000000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  h[0]=atol(p);
  
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
  	h[i]=atol(p);
  }
  
  h[0]-=1;
  
  for(i=1;i<N;i++){
    if(h[i-1]>h[i]){
      printf("No\n");
      return 0;
    }
    if(h[i-1]<h[i]){
      h[i]-=1;
    }
  }
  
  printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3+7;
int p[MAXN],c[MAXN];
int dp[10005];
int main() {
      //  freopen("../in.txt","r",stdin);
      //  freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        string s;
        while(cin>>s) {
                int k = 1;
                for(int i=0;i<s.length();++i) {
                        if(i%2==1 && s[i]=='R') {
                                k = 0;
                                cout<<"No"<<endl;
                                break;
                        }
                        if(i%2==0 && s[i]=='L') {
                                k = 0;
                                cout<<"No"<<endl;
                                break;
                        }
                }
                if(k)   cout<<"Yes"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;
 
int main() {


				 fast
				 int l;
				 cin>>l;
				 double ans=0;

				ans=(double (l/3.0)*double (l/3.0)*double(l/3.0));
				 cout<<fixed<<setprecision(12)<<ans<<endl;
                return 0;
            }

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans = "No";
  rep(i,3){
    if(s[i]=='7') ans = "Yes";
  }
  cout << ans << endl;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  vector<ll> p(n), c(n);
  for (int i = 0; i < n; i++) cin >> p.at(i);
  for (int i = 0; i < n; i++) cin >> c.at(i);
  
  vector<vector<int>> G(n);
  for (int i = 0; i < n; i++) G[i].emplace_back(p[i] - 1);
  
  ll ans = -1e18;
  for (int i = 0; i < n; i++) {
    vector<ll> d(n, -1);
    d[i] = 0;
    ll keep = 0, move = 0;
    int now = i;
    while (true) {
      int next = G[now][0];
      move++;
      keep += c[next];
      if (d[next] == 0) break;
      d[next] = d[now] + 1;
      now = next;
    }
    //cout << move << endl;
    ll k2 = k;
    if (move <= k) {
      if (keep > 0) {
        keep *= (k2 / move) - 1;
        k2 = (k2 % move) + move;
        ll keep2 = 0, ans2 = 0;
        now = i;
        for (int j = 0; j < k2; j++) {
          now = G[now][0];
          keep2 += c[now];
          ans2 = max(ans2, keep2);
        }
        ans = max(ans, keep + ans2);
      }
      else {
        ll keep2 = 0, ans2 = 0;
        now = i;
        for (int j = 0; j < min(k2, n); j++) {
          now = G[now][0];
          keep2 += c[now];
          if (j == 0) ans2 = keep2;
          else ans2 = max(ans2, keep2);
        }
        ans = max(ans, ans2);
      }
    }
    else {
      ll keep2 = 0, ans2 = 0;
      now = i;
      for (int j = 0; j < min(k2, n); j++) {
        now = G[now][0];
        keep2 += c[now];
        if (j == 0) ans2 = keep2;
        else ans2 = max(ans2, keep2);
      }
      ans = max(ans, ans2);
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3964
#include <algorithm>
#include <cassert>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <tuple>
#include <vector>

using namespace std;

namespace
{

int reverse(int n)
{
	int res = 0;
	while (n != 0) {
		res *= 10;
		res += n % 10;
		n /= 10;
	}

	return res;
}

}

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

	std::cout << (n == reverse(n) ? "Yes" : "No") << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

void csolve(){
    long double a,b;
    cin >> a >>b;
    kaku(floor(a*b));

    //printf("%.12f\n",ans);
}

void bsolve(){
    ll n;
    cin >> n;

    ll t=1000000000000000000;
    ll ans=1;
    bool u=false;
    bool ok=false;
    rep(i,n){
        ll a;
        cin >>a;
        ans*=a;
        if(ans>t) u=true;
        if(a==0) ok=true;
    }
    if(u && !ok) ans=-1;
    kaku(ans);
}

void asolve(){
    ll a,b;
    cin >> a >>b;
    kaku(a*b);
}

map< ll, ll > prime_factor(ll n) {
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void dsolve(){
    ll n;
    cin >> n;
    map<ll,ll> mp=prime_factor(n);
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){

        for(ll i=1;i<=60;i++){
            if(itr->second >=i){
                mp[itr->first]-=i;
                ans++;
            }
            else{
                break;
            }
        }

    }
    kaku(ans);
}

int main(){
    dsolve();
}

Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

inline int getnum(string s, int idx){
	if(idx >= s.size())return 0;
	else return s[idx]-'0';
}

string add(string s, string t){
	reverse(ALL(s));
	reverse(ALL(t));
	int n=max(s.length(), t.length());
	string r;
	int ku=0;
	REP(i,n){
		int tmp = getnum(s,i)+getnum(t,i)+ku;
		r.PB(tmp%10+'0');
		ku=tmp/10;
	}
	if(ku)r.PB('0'+ku);
	reverse(ALL(r));
	while(r[0] == '0' && r.size() > 1)r.erase(0,1);
	if(r.size()>80)return "overflow";
	return r;
}

int main(){
	int t;
	cin >> t;
	REP(i,t){
		string s1,s2;
		cin>>s1>>s2;
		cout << add(s1,s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
// segment tree (abstract version)

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class M>
class segment_tree{
	int sz;
	vector<M> seg;
public:
	segment_tree(){}
	segment_tree(int n){ build(n); }
	template<class T>
	segment_tree(const vector<T>& a){ build(a); }
	void build(int n){
		for(sz=1;sz<n;sz<<=1);
		seg.assign(2*sz,M());
	}
	template<class T>
	void build(const vector<T>& a){
		int n=a.size();
		build(n);
		rep(i,n) seg[sz+i]=a[i];
		for(int i=sz-1;i>0;i--){
			seg[i]=seg[2*i]*seg[2*i+1];
		}
	}
	const M& operator[](int i)const{
		return seg[sz+i];
	}
	void update(int i,const M& x){
		i+=sz;
		seg[i]=x;
		for(i>>=1;i>0;i>>=1) seg[i]=seg[2*i]*seg[2*i+1];
	}
	M get(int l,int r)const{
		M lcum,rcum;
		for(int a=l+sz,b=r+sz;a<b;a>>=1,b>>=1){
			if(a&1) lcum=lcum*seg[a++];
			if(b&1) rcum=seg[--b]*rcum;
		}
		return lcum*rcum;
	}
	template<class N,class F>
	N query(int l,int r,const F& f){
		N lcum,rcum;
		for(int a=l+sz,b=r+sz;a<b;a>>=1,b>>=1){
			if(a&1) lcum=lcum*f(seg[a++]);
			if(b&1) rcum=f(seg[--b])*rcum;
		}
		return lcum*rcum;
	}
};

template<class T>
class sequence_monoid{
	vector<T> a;
public:
	sequence_monoid(){}
	sequence_monoid(const T& val):a(1,val){}
	sequence_monoid(const vector<T>& x):a(x){
		sort(a.begin(),a.end());
	}
	sequence_monoid operator*(const sequence_monoid& x)const{
		vector<T> res;
		merge(a.begin(),a.end(),x.a.begin(),x.a.end(),back_inserter(res));
		return res;
	}
	int lower_bound(const T& val)const{
		return std::lower_bound(a.begin(),a.end(),val)-a.begin();
	}
};

template<class T>
class add_monoid{
	T a;
public:
	add_monoid():a(){}
	add_monoid(const T& val):a(val){}
	add_monoid operator*(const add_monoid& x)const{
		return a+x.a;
	}
	T& get(){ return a; }
	const T& get()const{ return a; }
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<int> x(n),pre(n,-1);
	rep(i,n){
		x[i]=pre[a[i]];
		pre[a[i]]=i;
	}

	segment_tree<sequence_monoid<int>> S(x);
	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		auto ans=S.query<add_monoid<int>>(l,r,[&](const sequence_monoid<int>& x)->add_monoid<int>{
			return x.lower_bound(l);
		});
		printf("%d\n",ans.get());
	}

	return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set<PII> mp;
  FOR(i,1,n){
    int tmp = n - i;
    if(i == tmp) continue;
    mp.insert({min<int>(tmp,i),max<int>(tmp,i)});
  }
  
  cout << mp.size() << endl;
  return 0;
}


Measured memory_bytes: 23680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		System.out.println(a / 3);
	}

}

Measured memory_bytes: 22996