akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];
  while( scanf("%s",s)!= EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

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

  return 0;
}




Measured memory_bytes: 2040
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define ed "\n";
int main(){
    int m,d;
    cin >>m >> d;
    int cnt=0;
    for(int i=4; i<=m; i++){
        for(int j=22; j<=d; j++){
            if(j%10!=1 && j/10!=1){
                if((j%10)*(j/10)==i) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans;
int main() {
	scanf("%lld%lld",&n,&m);
	ans=min(n,m/2);
	n-=ans;
	m-=ans*2;
	ans+=m/4;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MOD = 1000000007;
int main(){
	long long int N,K,A,M,pI,mI,ans=1;
	vector<long long int> p,m;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>A;
		if(A<0)m.push_back(-A);
		else p.push_back(A);
	}
	sort(p.begin(),p.end());
	sort(m.begin(),m.end());
	if(p.size()==0 && K%2){
		for(int i=0;i<K;i++)ans=((-ans*m[i])%MOD+MOD)%MOD;
	}else{
		pI=p.size()-1;
		mI=m.size()-1;
		if(K%2){
			ans=p[pI]%MOD;
			pI--;K--;
		}
		for(int i=0;i<K/2;i++){
			if(mI-1<0 && pI-1<0){M=-p[0]*m[0]%MOD;}
			else if(mI-1<0){M=p[pI]*p[pI-1]%MOD;pI-=2;}
			else if(pI-1<0){M=m[mI]*m[mI-1]%MOD;mI-=2;}
			else if(p[pI]*p[pI-1]>=m[mI]*m[mI-1]){M=p[pI]*p[pI-1]%MOD;pI-=2;}
			else {M=m[mI]*m[mI-1]%MOD;mI-=2;}
			ans=(ans*M%MOD+MOD)%MOD;
		}
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

set<int> s[3];
int f(int a) {
    rep(i, 3) if (s[i].count(a)) return i;
    return -1;
}
int main() {
    s[0] = set<int>{1, 3, 5, 7, 8, 10, 12};
    s[1] = set<int>{4, 6, 9, 11};
    s[2] = set<int>{2};
    int x, y;
    cin >> x >> y;
    if (f(x) == f(y)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int result[3] = {0, 0, 0};
  for (size_t i = 0; i < 3; i++) {
    if (s[i] == 'a') result[0] = 1;
    if (s[i] == 'b') result[1] = 1;
    if (s[i] == 'c') result[2] = 1;
  }
  int total = 0;
  for (size_t i = 0; i < 3; i++) {
    total += result[i];
  }
  if (total == 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;

struct edge { int to, cap, rev; };

const int MAX_V = 210;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].emplace_back((edge){to, cap, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, (int)G[from].size() - 1});
}

void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int i = 0; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        bfs(s);
        if (level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, inf)) > 0) {
            flow += f;
        }
    }
}

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

    int X, Y, E;
    cin >> X >> Y >> E;

    rep(i, E) {
        int x, y;
        cin >> x >> y;
        add_edge(x, X + y, 1);
    }

    const int s = X + Y, t = s + 1;
    rep(x, X) {
        add_edge(s, x, 1);
    }
    rep(y, Y) {
        add_edge(X + y, t, 1);
    }

    cout << max_flow(s, t) << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
	private static Scanner sc=new Scanner(System.in);
	public static void  main(String[]agrs){
		double xa,ya,ra,xb,yb,rb,xab,yab,xly,rab;
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
		xa=sc.nextDouble();
		ya=sc.nextDouble();
		ra=sc.nextDouble();
		xb=sc.nextDouble();
		yb=sc.nextDouble();
		rb=sc.nextDouble();
		xab=Math.abs(xa-xb);
		yab=Math.abs(ya-yb);
		rab=Math.abs(ra-rb);
		xly=Math.sqrt(Math.pow(xab,2)+Math.pow(yab,2));
			if(ra>xly+rb)System.out.println(2);
			else if(rb>xly+ra)System.out.println(-2);
			else if(ra+rb>=xly)System.out.println(1);
			else if(ra+rb<xly)System.out.println(0);
		}
		
	}
}

Measured memory_bytes: 20496
N, K = map(int, input().split())
A = list(map(int, input().split()))

def f(x, n):
  i = 0
  while x != 0:
    cnt_bit[i] +=  x % abs(n)
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
    i += 1

def base(x, n):
  ret = []
  while x != 0:
    ret.append( x % abs(n))
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
  return ret

cnt_bit = [0]*50
Flag = True

for a in A:
  f(a, 2)

B = base(K, 2)
M = len(B)

for i in range(M):
  c1, c0 = cnt_bit[M-1-i], N - cnt_bit[M-1-i]
  if Flag:
    if c1 >= c0:
      if B[M-1-i] == 1:
        Flag = False
      B[M-1-i] = 0
  else:
    if c1 >= c0:
      B[M-1-i] = 0
    else:
      B[M-1-i] = 1

if K == 0:
  k = 0
else:
  k = int("".join(map(str, reversed(B))), 2)

ans = 0
for a in A:
  ans += a^k

print(ans)

Measured memory_bytes: 20496
#include <bits/stdc++.h>
using namespace std;
signed main(){
	int n;
  	char s[2][105];
  
  	cin>>n;
  	for(int i=0;i<2;i++){
      	for(int j=0;j<n;j++)
          	cin>>s[i][j];
    }

  for(int j=0;j<n;j++){
	  for(int i=0;i<2;i++){
        	cout<<s[i][j];
      }
  }
  cout<<endl;
	return(0);
}

Measured memory_bytes: 256
(n,m,*b),a,*q=[map(int,t.split())for t in open(0)]
t=[-1]*n
def r(x):
 while-1<t[x]:x=t[x]
 return x
def u(x):
 x,y=map(r,x)
 if x-y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
[*map(u,q)]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:x,*y=sorted(p)+[0];c+=x;b+=y[:-1];j-=p>[]
print((c+sum(sorted(b)[:j]),'Impossible')[k>n]*(k>0))

Measured memory_bytes: 138648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<=1000;i++)
    {
        if(i*a%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

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

vector<int> X(10);
int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;
long long ans;

void DFS(vector<int> A){
  if(A.size() == N){
    long long now = 0;
    for(int i = 0; i < Q; i++){
      if(A.at(b.at(i)-1) - A.at(a.at(i)-1) == c.at(i)) now += d.at(i);
    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while(A.back() <= M){
    DFS(A);
    A.back()++;
  }
}


int main(){
  cin >> N >> M >> Q;
  a = b = c = d = vector<int>(Q);
  for(int i = 0; i < Q; i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  DFS(vector<int>(1, 1));
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstring>
using namespace std;
using ll = long long;

ll dp[110][110][330];

void max_update(ll &a, ll b) {
  if (b > a) {
    a = b;
  }
}

int main() {
  int N;
  ll W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= i; j++) {
      for (int sum = 0; sum <= 3 * j; sum++) {
        if (dp[i][j][sum] < 0) {
          continue;
        }
        max_update(dp[i+1][j][sum], dp[i][j][sum]);
        if (j * w[0] + sum + w[i] <= W) {
          max_update(dp[i+1][j+1][sum + w[i] - w[0]], dp[i][j][sum] + v[i]);
        }
      }
    }
  }
  ll res = 0;
  for (int j = 0; j <= N; j++) {
    for (int sum = 0; sum <= 3 * j; sum++) {
      res = max(res, dp[N][j][sum]);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 31488
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

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

  int r , c;
  cin >> r >> c;
  int mat[r + 1][c + 1];
  int N;
  cin >> N;
  vector<int> color;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    while(x--){
      color.push_back(i + 1);
    }
  }
  int idc = 0;
  for(int i = 0; i < c; i++) {
    if(i % 2 == 0) {
      for(int j = 0; j < r; j++) {
        mat[j][i] = color[idc++];
      }
    }
    else {
      for(int j = r - 1; j >= 0; j--) {
        mat[j][i] = color[idc++];
      }
    }
  }

  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      cout << mat[i][j] <<" ";
    } 
    cout << '\n';
  }
}

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

int N, D;
int c=0;

int main(){
  if(scanf("%d %d", &N, &D)==0);
  int i=0;
  while((2*D+1)*i<N)i++;
  
  printf("%d", i);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;


void Gauss(vector<vector<int>> &A, int n){
    int cur = 0;
    rep(j, 60){
        if(cur == n) break;
        if(A[cur][j] == 0){
            For(i, cur+1, n)if(A[i][j]){
                rep(k, 60) A[cur][k] ^= A[i][k];
                break;
            }
        }
        if(A[cur][j] == 0) continue;
        rep(i, n)if(i != cur && A[i][j]){
            rep(k, 60) A[i][k] ^= A[cur][k];
        }
        ++cur;
    }
}

int main(){
    int n;
    scanf("%d", &n);
    lint a[n], x;
    vector<vector<int>> A = vector<vector<int>>(n, vector<int>(60, 0));
    x = 0;
    rep(i, n){
        scanf("%lld", &a[i]);
        x ^= a[i];
        rep(j, 60) A[i][j] = (a[i] >> (59-j)) & 1;
    }

    lint ans = 0;
    rep(j, 60){
        lint t = (x >> (59-j)) & 1;
        ans += t << (59-j);
        rep(i, n)if(t) A[i][j] = 0;
    }

    Gauss(A, n);

    rep(j, 60){
        lint tmp = 0;
        rep(i, n) tmp ^= A[i][j];
        ans += tmp << (60-j);
    }

    printf("%lld\n", ans);
}

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

using namespace std;

typedef pair<int, int> pii;

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

int n, m;
vector<pii> xy;

int main() {
    cin >> n >> m;
    rep(i, n) { int x, y; cin >> x >> y; xy.push_back({x, y}); }
    sort(xy.begin(), xy.end());
    rep(_, m) {
        int ans = 0;
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        rep(i, n) {
            if(xy[i].first < x1) continue;
            REP(j, i, n) {
                if(xy[j].first > x2) break;
                if(y1 <= xy[j].second && xy[j].second <= y2) ans++;
            }
            break;
        }
        cout << ans << endl;
    }
}



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

template <typename Container>
void create_backtrace_table(
    const Container &w,
    std::vector<int> &t)
{
  t.clear();
  t.resize(w.size() + 1);

  t[0] = -1;
  t[1] = 0;

  size_t i = 2, j = 0;
  while(i < t.size()) {
    if(w[i-1] == w[j]) {
      t[i] = j + 1;
      i++; j++;
    } else if(j > 0) {
      j = t[j];
    } else {  // j==0
      t[i] = 0;
      i++;
    }
  }
}

template <typename Container>
void find_by_kmp(
    const Container &s,
    const Container &w,
    const std::vector<int> & t,
    std::vector<int> &pos)
{
  pos.clear();
  size_t m = 0; // index of s
  int i = 0; // index of w

  if(s.size() < w.size()) {
    return;
  }

  // std::cout << "start m = " << m << std::endl;
  while(m <= s.size()) {
    // std::cout << "m = " << m
    //           << " i = " << i
    //           << std::endl;
    // matching
    if(i < (int)w.size() && s[m + i] == w[i]) {
      i++;
      continue;
    }

    // matching complete or mismatch
    if(i == (int)w.size()) {
      pos.push_back(m);
    }

    m += i - t[i];
    if(i > 0) i = t[i];
  }
}

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto &x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<uint32_t> a(N), b(N);

  for(int i=0; i<N; i++) {
    std::cin >> a[i];
  }
  for(int i=0; i<N; i++) {
    std::cin >> b[i];
  }

  std::vector<uint32_t> diff_a(N), diff_b(2*N);
  for(int i=0; i<N; i++) {
    diff_a[i] = a[i] ^ a[(i+1) % N];
    diff_b[i] = b[i] ^ b[(i+1) % N];
    diff_b[i + N] = diff_b[i];
  }

  // print_container(diff_a, "diff_a");
  // print_container(diff_b, "diff_b");
  std::vector<int> t, pos;
  create_backtrace_table(diff_a, t);
  // print_container(t, "t");
  find_by_kmp(diff_b, diff_a, t, pos);
  // print_container(pos, "pos");

  if(pos.empty()) {
    goto END;
  }
  if(pos[0] == 0) {
    std::cout << "0" << " " << (a[0] ^ b[0]) << std::endl;
  }
  std::sort(pos.begin(), pos.end(), std::greater<int>());
  for(auto p: pos) {
    if(N <= p) continue;
    if(p == 0) continue;
    std::cout << (N - p)  << " " << (a[0] ^ b[p]) << std::endl;
  }

END:
  return 0;
}


Measured memory_bytes: 9264
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int N;
int num[1001];
int yoko[1001][1001];

int count(string s){
    int a=0;
    REP(i,s.size()){
        if(s[i]=='.'){
           a++;
        }
    }
    return a;
}
string sep(string s){
   string str="";
   REP(i,s.size()){
       if(s[i]!='.')str.push_back(s[i]);
   }
   return str;
}

int main(){
    while(cin>>N,N){
        REP(i,1001){
            REP(j,1001){
                yoko[i][j]=0;
            }
            num[i]=0;
        }
        vector<string>s;
        REP(i,N){
            string str;
            cin>>str;
            num[i]=count(str);
            s.push_back(sep(str));
        }
        REP(i,N){
           REP(j,1001){
              yoko[i][j]=0;
           }
        }
       REP(i,N){
          int now=num[i];
          yoko[i][now]=1;
          for(int j=i+1;j<N;j++){
              if(now>num[j]){
                 yoko[i][num[j]]=2;
                 now=num[j];
              }
          }
       }
       REP(i,N){
           REP(j,num[i]+1){
               if(j==0)continue;
               if(yoko[i][j]==0){
                  cout<<" ";
               }
               if(yoko[i][j]==1){
                  cout<<"+";
               }
               if(yoko[i][j]==2){
                  cout<<"|";
               }
           }
           cout<<s[i]<<endl;
       }
    }
    return 0;
}

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

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



int main() {
    int h,w,ans=0; cin>>h>>w;
    int x,y;
    queue<pp> que;
    vector<vector<int>> mp(h+2,vector<int>(w+2,0));
    vector<vector<int>> dir={{1,0},{0,1},{-1,0},{0,-1}};
    rep(i,h){
        rep(j,w){
            char ch; cin>>ch;
            if(ch=='.') mp[i+1][j+1]=-1;
            if(ch=='#') que.push(mk(i+1,j+1));
        }
    }
    while(!(que.empty())){
        tie(x,y)=que.front(); que.pop();
        for(auto p : dir){
            if(mp[x+p[0]][y+p[1]]<0){
                mp[x+p[0]][y+p[1]]=mp[x][y]+1;
                que.push(mk(x+p[0],y+p[1]));
                ans=max(ans,mp[x][y]+1);
            }
        }
    }
    cout<<ans<<endl;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int d[110];
    REP(i,N) cin >> d[i];
    map<int, int> M;
    int ans = 0;
    REP(i,N){
        if(M.count(d[i])) continue;
        else{
            M[d[i]] = 0;
            ans++;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;


int main(){
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	for (int i = 0; i < a; i++){
		if (s[i] == '-'){
			cout << "No" << endl;
			return 0;
		}
	}
	if (s[a] != '-'){
		cout << "No" << endl;
		return 0;
	}
	for (int i = a+1; i <= a+b+1; i++){
		if (s[i] == '-'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3608
def main():
    import sys
    input = lambda : sys.stdin.readline().rstrip()

    from heapq import heappush, heappop 

    running = []
    events = []
    delete = set()

    n, q = map(int, input().split())
    for _ in range(n):
        s, t, x = map(int, input().split())
        events.append((s - x, x, 1)) # 追加イベント
        events.append((t - x, x, 0)) # 削除イベント
    for _ in range(q):
        d = int(input())
        events.append((d, 10**10, 2))
    events.sort()
    for i in range(len(events)):
        temp = events[i]
        if temp[-1] == 1:
            heappush(running, temp[1])
            delete.discard(temp[1])
        elif temp[-1] == 0:
            delete.add(temp[1])
        else:
            flag = 1
            while running:
                p = heappop(running)
                if p not in delete:
                    flag = 0
                    heappush(running, p)
                    print(p)
                    break
            if flag:
                print(-1)
if __name__ == '__main__':
    main()





Measured memory_bytes: 91716
/* 
 * Author: aps
 * Time: 2019-08-13 19:02:24
**/
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    string s; cin >> s;
    int n = s.length();

    int cnt[n], pos[n];
    fill(cnt,cnt+n,0);
    fill(pos,pos+n,0);

    int x = 0;
    for(int i=0;i<n;i++){
        if(s[i] == 'L') pos[i] = x;
        else x = i;
    }

    x = n-1;
    for(int i=n-1; i>=0 ; i--){
        if(s[i] == 'R') pos[i] = x;
        else x = i;
    }

    for(int i=0;i<n;i++){
        if(s[i] == 'L'){
            x = i - pos[i];
            if(x&1) cnt[pos[i]+1]++;
            else cnt[pos[i]]++;
        } else {
            x = pos[i] - i;
            if(x&1) cnt[pos[i]-1]++;
            else cnt[pos[i]]++;
        }
    }

    for(int i=0;i<n;i++) cout << cnt[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1488
h,n=map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]

dp=[float('inf')]*(h+1)
dp[0]=0
for i in range(h):
    for j in range(n):

        next=i+ab[j][0] if i+ab[j][0]<=h else h
        dp[next]=min(dp[next],dp[i]+ab[j][1])
print(dp[-1])


Measured memory_bytes: 73996
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const long long INF=1000000007;
using ll=long long;


//vars;
int W,H,ans=0,shortest_pass=0;
char s[55][55];

int BFS(){
	//前後左右に動くことを想定するため,
	//(x,y)を(x+dx[i],y+dy[i])に移動させることを考える.
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	queue<P> que;
	//初期位置からの距離(distance)を調べる.
	int dist[55][55];
	//わかりやすさのため,初期位置を(0,0)ではなく(1,1)にした.
	//すべての点をINF(=未訪であるというフラグ)にする.
	rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
	//最初の点をスタートでありゴールと考えると,
	//dist[1][1]==1である.
	dist[1][1]=1;
	//まず最初は(1,1)を起点にして考える.
	que.push(P(1,1));
	//s[i][j]がゴール,もしくはゴールに行けないと
	//わかったときに終了する.
	while(que.size()){ 
		P p=que.front();
		que.pop();
		rep(i,0,4){
			//まず(1,1)の前後左右を調べる.
			int next_x=p.first+dx[i];
			int next_y=p.second+dy[i];
			if(s[next_x][next_y]=='.'&&
				next_x>=1&&next_x<=W&&
				next_y>=1&&next_y<=H&&
				dist[next_x][next_y]==INF){
				que.push(P(next_x,next_y));
				dist[next_x][next_y]=dist[p.first][p.second]+1;
			}
		}
	}
	return dist[W][H];
}

int main() {
	//input;
	cin>>H>>W;
	rep(j,1,H+1)rep(i,1,W+1){
		cin>>s[i][j];
		//'.'の点を数える.
		if(s[i][j]=='.')ans++;
	}

	//output;
	shortest_pass=BFS();
	//ゴールに行けないとき,dist[W][H]は更新されず
	//INFのままなので,"-1"を出力する.
	if(shortest_pass==INF)cout<<"-1"<<endl;
	//ゴールに行けるとき、その最短コース以外の'.'は
	//全て'#'にでき,これが最大値である.
	else cout<<ans-shortest_pass<<endl;
}

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


bool reachable(string s,int start,int end){
	bool res=true;
	for(int i = start-1;i<end-1;i++){
		if(s[i]=='#' & s[i+1]=='#'){
			res=false;
			break;
	 	}
	}
	return res;
}

int main(){
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d;
	cin >> s;
	bool TF = true;

	if(reachable(s,a,c) & reachable(s,b,d)) TF=true;
	else TF=false;
	if(c>d){
		bool sunuke_can_go_over_hunuke=false;	
		for(int i=b-2;i<d-1;i++){
			if(((s[i]=='.') & (s[i+1]=='.')) & (s[i+2]=='.')){
				sunuke_can_go_over_hunuke=true;
			}
		}
		TF=(TF & sunuke_can_go_over_hunuke);
	}
	if(TF) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 1088
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n) {
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n << ":" << endl;
	for (int i = 2; i <= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n,k,a,ans;
pair<int,int>P[200005];
signed main() {
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a;
		P[a].first++;
		P[a].second=a;
	}
	sort(P,P+n);
	reverse(P,P+n);
	for(int i=0;i<k;i++){
		ans+=P[i].first;
	}
	cout<<n-ans<<endl;
}



Measured memory_bytes: 3328
var i,n:integer;
begin
  readln(n);
  if n<3 then writeln(4) else begin
    i := 2;
    while n > 1 do begin
      i := i + 1;
      if n mod 2 = 0 then
        n := n div 2
      else
        n := n * 3 + 1
    end;
  writeln(i);
  end
end.

Measured memory_bytes: 128
n, k, c = map(int, input().split())
s = input()

# num 回目に働く日は l[num-1] 日目以降
l = []
num = 0 # num = len(l)
i = 0
while num < k:
    if s[i] == 'o':
        l.append(i)
        num += 1
        i += c + 1
    else:
        i += 1

# num 回目に働く日は l[num-1] 日目以前
r = []
num = 0 # num = len(r)
i = n - 1
while num < k:
    if s[i] == 'o':
        r.append(i)
        num += 1
        i -= c + 1
    else:
        i -= 1
r.reverse()

for i in range(k):
    if l[i] == r[i]:
        print(l[i] + 1)

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

using ll=long long;

int main() {
  int N,K; cin >>N >>K;
  vector<int> p(N);
  rep(i,0,N) cin >>p[i];
  sort(p.begin(),p.end());
  int ans=0;
  rep(i,0,K) ans+=p[i];
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  while(1){
    int a,c,b,n,x,y[100];
    cin>>n>>a>>b>>c>>x;
    if(n+a+b+c+x==0)break;
    for(int i=0;i<n;i++){
      cin>>y[i];
    }
    int cnt=0,count=0;
    while(1){
	if(x==y[cnt]){
	  cnt++;
	}
      if(cnt==n){
	cout<<count<<endl;
	break;
      }
      if(count==10000){
	cout<<-1<<endl;
	break;
      }
      x=(a*x+b)%c;
      count++;
    }    
  }
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define INFTY (1<<30)

int n;
vector<int> color(101,0),d(101,INFTY),p(101);
vector<vector<int>> M(101,vector<int>(101,INFTY));

void dijkstra(int s){
    d[s]=0;
    p[s]=-1;
    while(1){
        int u;
        int mincost=INFTY;
        for(int i=0;i<n;i++){
            if(color[i]!=2&&d[i]<mincost){
                mincost=d[i];
                u=i;
            }
        }
        if(mincost==INFTY) break;
        color[u]=2;
        for(int v=0;v<n;v++){
            if(color[v]!=2&&M[u][v]!=INFTY){
                if(d[u]+M[u][v]<d[v]){
                    d[v]=d[u]+M[u][v];
                    p[v]=u;
                    color[v]=1;
                }
            }
        }
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b,c,k;
        cin>>a>>k;
        for(int j=0;j<k;j++){
            cin>>b>>c;
            M[a][b]=c;
        }
    }

    dijkstra(0);

    for(int i=0;i<n;i++){
        cout<<i<<' '<<d[i]<<endl;
    }
}


Measured memory_bytes: 3184
#include <cstdio>
int n, a, b, now;
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i * b <= n; ++i) {
    int j = n+1-a-(b-1)*i;
    if (!i && j < b) continue;
    if (n - b * i - j >= 0 && j <= b && j > 0) {
      for (int k = 1; k <= i; ++k)
        for (int l = 1; l <= b; ++l) printf("%d ", k * b - l + 1), ++now;
      for (int k = 1; k <= j; ++k)
        printf("%d ", now + j + 1 - k);
      now += j;
      while (now < n) printf("%d ", ++now);
      return 0;
    }
  }
  printf("-1"); return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  int p = 1;
  int ans = 0;
  rep(i,n) {
    if(i >= 1 && a[i] == a[i-1]) p++;
    else {
      ans += p/2;
      p = 1;
    } 
  }
  ans += p/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//Main(`5
//3 3 3 3 3`);

function Main(line) {
  let [firstline, ...data] = line.trim().split("\n");

  const N = Number(firstline);
  data = data[0].split(" ").map(Number);

  let crt = data[0];
  let keep = [];
  let rst = [];
  for (let i = 1; i < data.length; i++) {
    //더 크면
    if (data[i] > crt) {
      while (keep.length > 0) {
        const v = keep.pop();
        rst.push(crt - v);
      }
      crt = data[i];
    }
    if (data[i] < crt) {
      keep.push(data[i]);
    }
  }
  while (keep.length > 0) {
    const v = keep.pop();
    rst.push(crt - v);
  }

  const sum = rst.reduce((acc, crt) => acc + crt, 0);
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 58028
#include<bits/stdc++.h>
using namespace std;
main(){
    int n;cin>>n;
    int a[n],b[n]; for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    sort(a,a+n),sort(b,b+n);
    n&1?cout<<b[n/2]-a[n/2]+1:cout<<(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1;
}


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

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

    std::vector<std::string> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<std::string> b(m);
    for (int i = 0; i < m; i++) {
        std::cin >> b[i];
    }

    for (int i = 0; i < n - m + 1; i++) {
        for (int j = 0; j < n - m + 1; j++) {
            int cnt = 0;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (a[i + k][j + l] == b[k][l]) {
                        cnt++;
                    }
                }
            }

            if (cnt == m * m) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
using System;

public class Test
{
    public static void Main()
    {
        int W, H, x, y, r;
        string[] str = Console.ReadLine().Split(' ');
        W = int.Parse(str[0]);
        H = int.Parse(str[1]);
        x = int.Parse(str[2]);
        y = int.Parse(str[3]);
        r = int.Parse(str[4]);

        if (0<=x-r && 0<=y-r && x+r<=W && y+r<=H)
        {
        Console.WriteLine("Yes");
        }

        else
        {
        Console.WriteLine("No");
        }

    }
}


Measured memory_bytes: 19856
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
using namespace std;

int main(){
    // fast i/o
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

//    int t;
//    cin>>t;
//    while(t--){

//    }

    string s;
    cin>>s;
    int flg=0;
    fo(i,s.length()){
        if(i==2 || i==4){
            if(s[i]==s[i+1]){
                continue;
            }
            else{
                flg=1;
                break;
            }
        }
    }
    if(flg){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int h, w, m;
  cin >> h >> w >> m;
  vector<ll> yoko(w, 0);
  vector<ll> tate(h, 0);
  map<pair<int, int>, int> mp;
  
  rep(i, m) {
    int x, y;
    cin >> y >> x;
    x--; y--;
    yoko.at(x)++;
    tate.at(y)++;
    mp[make_pair(x, y)]++;
  }

  vector<int> tatemx(h, 0);
  vector<int> yokomx(w, 0);
  auto tateit = max_element(tate.begin(), tate.end());
  auto yokoit = max_element(yoko.begin(), yoko.end());
  ll yokomx_cnt = 0;
  ll tatemx_cnt = 0;
  rep(i, w) {
    if (yoko.at(i) == *yokoit) {
      yokomx.at(i) = 1;
      yokomx_cnt++;
    }
  }
  rep(i, h) {
    if (tate.at(i) == *tateit) {
      tatemx.at(i) = 1;
      tatemx_cnt++;
    }
  }

  ll ans = 0;
  ll v = *tateit + *yokoit;
  ll cnt = 0;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    if (yokomx.at(it->first.first) && tatemx.at(it->first.second)) cnt++;
  }
  if (yokomx_cnt * tatemx_cnt != cnt) {
    cout << v << endl;    
  } else {
    cout << v-1 << endl;
  }
  

  
  // ll ans = 0;

  //   ll tmp = yoko_v + tate.at(i) - mp[make_pair(yoko_i, i)];
  //   ans = max(ans, tmp);
  // }

  
  return 0;
}

Measured memory_bytes: 29008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[120];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1;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]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])ans++;
            printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
		cout << "Yes" << endl;
	} else if (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) {
		cout << "Yes" << endl;
	} else if (s[0] == s[3] && s[0] != s[1] && s[1] == s[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int data[12][12];

	while( cin >> n && n != 0 ){
		for( int i = 0;i < n;i++ ){
			for( int j = 0;j < n;j++ ){
				cin >> data[i][j];
			}
		}

		int sum = 0;
		for( int i = 0;i < n;i++ ){
			sum = 0;
			for( int j = 0;j < n;j++ ){
				sum += data[i][j];
			}
			data[i][n] = sum;
		}
		for( int i = 0;i < n + 1;i++ ){
			sum = 0;
			for( int j = 0;j < n;j++ ){
				sum += data[j][i];
			}
			data[n][i] = sum;
		}

		for( int i = 0;i < n + 1;i++ ){
			for( int j = 0;j < n + 1;j++ ){
				cout.width( 5 );
				cout << data[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  int x[5];
  for (int i = 0; i < 5; i++)
    cin >> x[i];
  sort(x, x + 5);
  int k;
  cin >> k;
  string ans = "Yay!";
  if (x[4] - x[0] > k)
    ans = ":(";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    vector<int> B = A;
    sort(B.begin(), B.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int val = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
        ans += (val ^ i) & 1;
    }
    cout << ans / 2 << '\n';
}

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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string a = s.substr(0, n / 2);
    string b = s.substr(n / 2, n / 2);
    // cout << a << ' ' << b << endl;
    if (n % 2)
    {
        cout << "No" << endl;
        return 0;
    }
    if (a == b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
ans = 0
now = H[0]
count = 0
for i in range(1,N):
    if now >= H[i]:
        count += 1
        now = H[i]
    else:
        now = H[i]
        ans = max(ans,count)
        count = 0
ans = max(ans,count)
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x,y) make_pair(x,y);
/*struct comp
{
    bool operator()()
    {
        
    }
};*/

int32_t main() {
    
    int A,B,N;
    cin>>A>>B>>N;
    cout<<(A*min(N,B-1))/B;
    
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);

  for (int i = 0; i < a; ++i) cin >> p[i];
  for (int i = 0; i < b; ++i) cin >> q[i];
  for (int i = 0; i < c; ++i) cin >> r[i];

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.begin(), r.end());

  priority_queue<ll, vector<ll>, greater<ll> > pp;
  priority_queue<ll, vector<ll>, greater<ll> > qq;
  for (int i = 0; i < x; ++i) pp.push(p[i]);
  for (int i = 0; i < y; ++i) qq.push(q[i]);

  for (int i = 0; i < c; ++i) {
    if (pp.top() < qq.top()) {
      if (pp.top() < r[i]) {
	pp.pop();
	pp.push(r[i]);
      }
    } else {
      if (qq.top() < r[i]) {
	qq.pop();
	qq.push(r[i]);
      }
    }
  }

  ll ans = 0;
  while (!pp.empty()) {
    ans += pp.top(); pp.pop();
  }
  while (!qq.empty()) {
    ans += qq.top(); qq.pop();
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 4852
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int a[200010];
int b[200010];
vector<pair<int, int>> v;
int main()
{
    int n;
    cin >> n;
    REP(i, n)
    {
        int x, y;
        cin >> x >> y;
        v.push_back(make_pair(y, x));
    }
    sort(v.begin(), v.end());
    ll sum = 0;
   /*  for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i].second << " " << v[i].first << endl;
    }*/

    for (int i = 0; i < n; i++)
    {
        sum += v[i].second;
        if(sum<=v[i].first){
            continue;
        }
        else{
            cout << "No" << endl;
           // cerr << v[i].second << " " << v[i].first << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 2420
namespace ABC126_B
{
    using static System.Console;

    public class Program
    {
        static void Main(string[] args)
        {
            WriteLine(Solve(ReadLine()));
        }

        public static string Solve(string s)
        {
            var first = s.Substring(0, 2);
            var last = s.Substring(2, 2);

            var isFirstMonth = CheckMonth(first);
            var isLastMonth = CheckMonth(last);

            if (isFirstMonth && isLastMonth) return "AMBIGUOUS";
            if (isFirstMonth) return "MMYY";
            if (isLastMonth) return "YYMM";
            return "NA";
        }

        public static bool CheckMonth(string s)
        {
            var m = int.Parse(s);
            if (0 < m && m <= 12) return true;
            return false;
        }

    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	char now = s[0];
	for(int i = 1; i < n; i++){
		if(s[i] != now){
			ans++;
			now = s[i];
		}
	}
	cout << ans << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
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 gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C;
    cin >> A >> B >> C;

    if(A >= B){
        if(A>= C){
            cout << A*10+B+C << endl;
            return 0;
        }
    }
    if(B >= A){
        if(B>= C){
            cout << B*10+A+C << endl;
            return 0;
        }
    }
    if(C >= A){
        if(C >= B){
            cout << C*10+A+B << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char k[1000000];
int main()
{
	scanf("%s",k);
	int c = strlen(k);
	for(int i=0;i<c;i++)
	{
		if((i+1) % 2 == 1)
		printf("%c",k[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
h,w= (int(i) for i in input().split())

s= [ ["_" for i in range(w + 2)] ]
for i in range(h):
    s.append(list("_" + input() + "_"))
s.append(["_" for i in range(w + 2)])

for i in range(1,h + 1):
    for j in range(1,w + 1):
        if s[i][j] == ".":
            s[i][j] = str((s[i-1][j-1] + s[i-1][j] + s[i-1][j+1]
            + s[i][j-1] +  s[i][j+1]
            + s[i+1][j-1] + s[i+1][j] + s[i+1][j+1]).count("#"))


for i in range(1, h+1):
    print ("".join(s[i]).replace("_","")) 



Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	var b string
	fmt.Scan(&b)
	switch b {
	case "A":
		fmt.Println("T")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	case "T":
		fmt.Println("A")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
using namespace std;


int main(){
  string A, B, C; cin >> A >> B >> C;
  string ans = "YES";
  if(A.back() != B.front()) ans = "NO";
  if(B.back() != C.front()) ans = "NO";
  cout << ans << endl;
}


Measured memory_bytes: 256