akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
 
#define M 1046527
#define NIL (-1)
#define L 14
 
char H[M][L];
 
int getChar(char ch) {
    if (ch == 'A')return 1;
    else if (ch == 'C')return 2;
    else if (ch == 'G')return 3;
    else if (ch == 'T')return 4;
    else return 0;
}
 
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
 
int h1(int key) { return key%M; }
int h2(int key) { return 1 + (key % (M - 1)); }
 
int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0)return 1;
        else if (strlen(H[h]) == 0)return 0;
    }
    return 0;
}
 
int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0)return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}
 
int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++)H[i][ 0 ] = '\0';
    scanf("%d",&n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
 
        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 16016
import collections

h,w,m = map(int,input().split())
X = []
Y = []
for _ in range(m):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
#まず一番大いX座標を調べる
most_common_x = collections.Counter(X).most_common()
most_common_x_index = most_common_x[0][0] #x座標
most_common_x_count = most_common_x[0][1] #その線に存在する爆弾の個数
#爆破されない座標たちの共通するY座標を探す
otherwise = []
for i in range(m):
    if X[i] != most_common_x_index:#not most common
        otherwise.append(Y[i])
most_common_y = collections.Counter(otherwise).most_common()
if len(most_common_y)!= 0: #ある特定のyが存在した時
    ansx = most_common_y[0][1] + most_common_x_count
else: #もともと全部のy座標が揃っていた時
    ansx = most_common_x_count
#次にY座標を基準にして調べる
most_common_y = collections.Counter(Y).most_common()
most_common_y_index = most_common_y[0][0] #x座標
most_common_y_count = most_common_y[0][1] #その線に存在する爆弾の個数
otherwise = []
for i in range(m):
    if Y[i] != most_common_y_index:#not most common
        otherwise.append(X[i])
most_common_x = collections.Counter(otherwise).most_common()
if len(most_common_x)!= 0 :
    ansy = most_common_x[0][1] + most_common_y_count
else:
    ansy = most_common_y_count
print(max(ansx,ansy))

Measured memory_bytes: 118044
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    size_t N;
    std::cin >> N;

    boost::multi_array<char, 2> m(boost::extents[N][N]);
    for (auto p = m.data(); p < (m.origin() + m.num_elements()); ++p) {
        std::cin >> *p;
    }

    size_t count = 0;
    for (size_t a = 0; a < N; ++a) {
        //for (size_t b = 0; b < N; ++b) {
            // cerr << "A B " << a << " " << b << endl;
            bool good = true;
            for (size_t i = 0; i < N; ++i) {
                for (size_t j = 0; j < N; ++j) {
                    auto ai = (a + i) % N;
                    auto bi = (0 + i) % N;
                    auto aj = (a + j) % N;
                    auto bj = (0 + j) % N;
                    if (i != j && m[ai][bj] != m[aj][bi]) {
                        good = false;
                        goto NO;
                    }
                }
            }
        NO:
            if (good) {
                count += N;
            }
       //}
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

void solve(long long K, long long N, std::vector<long long> A)
{
  lli sum = 0;
  rep(i, N - 1)
  {
    sum += A[i + 1] - A[i];
  }
  sum += K - A[N - 1] + A[0];
  lli ans = sum;
  rep(i, N - 1)
  {
    chmin(ans, sum - (A[i + 1] - A[i]));
  }
  chmin(ans, sum - (K - A[N - 1] + A[0]));
  cout << ans << endl;
}

signed main()
{
  long long K;
  scanf("%lld", &K);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(K, N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 1792
N = int(input())
rabit = [ int(v) for v in input().split(" ") ]
skip = set()
num = 0
 
for i in range(N):
  n = rabit[i]
  if i in skip:
    continue
  if rabit[n-1] == i+1:
    skip.add(n-1)
    num += 1
 
print(num)

Measured memory_bytes: 20544
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<random>
#include<map>
using namespace std;
#define int long long
typedef pair<double,int> P;
struct edge { int to; double cost; };
double d[1005];
double x[1005], y[1005], r[1005];
vector<edge>G[1005];

double dis(double sx, double sy, double gx, double gy) {
	return sqrt((sx - gx)*(sx - gx) + (sy - gy)*(sy - gy));
}

void dijk(int s) {
	fill(d, d + 1005, 10000000000000000);
	priority_queue<P, vector<P>, greater<P> >Q;
	d[s] = 0;
	Q.push(P(0, s));

	while (Q.size()) {
		P p = Q.top();
		Q.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				Q.push(P(d[e.to], e.to));
			}
		}
	}
}

signed main() {
	double xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[n] = xs, y[n] = ys;
	x[n + 1] = xt, y[n + 1] = yt;
	n += 2;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			double ds = max(0.00, dis(x[i], y[i], x[j], y[j])-r[i]-r[j]);
			G[i].push_back({ j,ds });
			G[j].push_back({ i,ds });
		}
	}
	dijk(n-2);
	printf("%.13lf\n", d[n - 1]);
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int>> d(n);
    int cnt = 0;
    REP(i,n){
        cin >> d[i].first >> d[i].second;
    }
    bool is = false;
    vector<bool> isv(n);
    REP(i,n){
        if(d[i].first == d[i].second){
            isv[i] = true;
        }else{
            isv[i] = false;
        }
    }

    REP(i,n){
        if(isv[i] == true){
            cnt++;
        }else{
            cnt = 0;
        }

        if(cnt >= 3){
            is = true;
        }
    }

    if(is){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

struct pp {
	int val;
	int ind;
	bool operator < (const pp& el) const {
		return ((val < el.val) || (val == el.val && ind < el.ind));
	}
};

int main() {
	int n, k;
	cin>>n>>k;
	int a[200005];
	pp pref[200005];
	pref[0] = {0, 0};
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
		a[i]--;
		pref[i].val = (pref[i - 1].val + a[i]) % k;
		pref[i].ind = i;
	}
	sort(pref, pref + n + 1);
	/*for (int i = 0; i <= n; i++)
		cout<<pref[i]<<" ";
	cout<<endl;*/
	long long res = 0;
	for (int i = 0; i <= n;) {
		int j = i;
		while ((j + 1 <= n) && (pref[i].val == pref[j + 1].val))
			j++;
		int right = i;
		for (int left = i; left <= j; left++) {
			while (right <= j && (pref[right].ind - pref[left].ind < k))
				right++;
			res += right - left - 1;
		}
		i = j + 1;
	}
	cout<<res;
}

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

int main() {
  int x;
  cin >> x;
  
  for(int a = -150; a < 150; ++a) {
    for(int b = -150; b < 150; ++b) {
      if(pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }  

  return 0;
}


Measured memory_bytes: 3992
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		int ret = 0;
		for (int i = 0;i < 100000000;i++) {
			if (a%2!=0||b%2!=0||c%2!=0) {
				System.out.println(ret);
				return;
			}
			long ta = a/2;
			long tb = b/2;
			long tc = c/2;
			a = tb + tc;
			b = ta + tc;
			c = ta + tb;
			ret++;
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 23124
from itertools import permutations

N, M = map(int, input().split())
path = [[False] * N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    path[a][b] = path[b][a] = True

    ans = 0
    for i in permutations(range(N), N):
        if i[0] == 0:
            for j in range(N):
                if j == N - 1:
                    ans += 1
                    break
                if not path[i[j]][i[j + 1]]:
                    break

print(ans)

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


int main() {
    int n,k,ans=0;
    cin>>n>>k;
    int a[n+1]={0};
    while(k--)
    {
        int d,aa;
        cin>>d;
        while(d--)
        {
            int aa;
            cin>>aa;
            a[aa]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        ans++;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200005];
int main()
{
	int n;
	cin>>n;
	int flag=0,d=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]==1&&!flag) d=i;
		if(a[i]==1) flag=1;
	}
	if(!flag){
		cout<<"-1"<<endl;
	}else{
		int c=2,cnt=1;
		for(int i=d+1;i<n;i++){
			if(a[i]==c){
				c++;
				cnt++;
			}
		}
		printf("%d\n",n-cnt);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N ;
  bool result=0;
  for (int i=1;i<10;i++){
    for (int j=1;j<10;j++){
      if(i*j==N){
        result=1;
      }
    }
  }
  if (result==0){
    cout << "No" <<endl;
  }
  else{
    cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10000005
#define ll long  long
#define upperlimit 1000100
#define INF 1e18
#define inf 1e9
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mod 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define ios ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll z[100004],a[100003];
vector<ll>b[100004];
void ans(long i)
{
    ll k=0;
    ll p=1;
    set<pll>s;
    for(int j=0;j<b[i].size();j++)
    {

        ll h=b[i][j];
        ans(h);
        s.insert(mp(z[h],h));
       // k=max(k,p+z[h]);
        //p++;
    }
    p=b[i].size();
    while(!s.empty())
    {
        ll h=s.begin()->FF;
        s.erase(s.begin());
        k=max(k,p+h);
        p--;
    }
    z[i]=k;


}
int main()
{
    int n;
    cin>>n;
    for(int i=2;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]].push_back(i);
    }
    ans(1);
    cout<<z[1]<<endl;




}


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

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> r(n);
  ll r1 = 0;
  rep(i, n) {
    if(i % 2 == 0) r1 += a[i];
    else r1 -= a[i];
  }
  r[0] = r1;
  for(int i = 1; i <n; i++) r[i] = 2 * a[i-1] - r[i-1];
  rep(i, n) cout << r[i] << " ";
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
ll T;

const int MAXN =1e5+10;
ll a[MAXN],b[MAXN];
ll N;

int main() {
	scanf("%lld",&N);
	for(ll i=0;i<N;i++)	scanf("%lld",&a[i]);
	for(ll i=0;i<N;i++)	scanf("%lld",&b[i]);
	ll fu = 0,zh = 0;
	for(ll i=0;i<N;i++){
		if(a[i]<=b[i]){
			fu+=(b[i]-a[i])/2;
		}else{
			zh+=(a[i]-b[i]);
		}
	}
	if(fu<zh)	printf("No\n");
	else	printf("Yes\n");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	int N , K; cin >> N >> K;
	int res = 0;

	res = ((N - 1) % (K - 1) == 0) ? (N - 1) / (K - 1) : (N - 1) / (K - 1) + 1;

	cout << res << endl;

}

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

int main() {
    int N; cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a; cin >> a;
        mp[a]++;
    }
    int ans = mp.size();
    if(ans % 2 == 0) ans--;
    cout << ans << '\n';
    return 0;
}


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

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

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
template <class E>
using Graph = vector<vector<E>>;

// dfs
ll K;
ll ans = 1;
Graph<int>	G;
void dfs(int from, int to, int depth, int tonariNum)
{
	ll depMax = min(2, depth);
	ll colNum = K - depMax - tonariNum;
	ans *= colNum;
	ans %= MOD;

	ll tonariCnt = 0;
	for (auto nextTo : G[to]) {
		if (nextTo != from) {
			dfs(to, nextTo, depth + 1, tonariCnt);
			tonariCnt++;
		}
	}
}

// メイン
int main()
{
	ll N;
	cin >> N >> K;
	G.resize(N);
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	dfs(-1, 0, 0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define Mx 2000001
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);

typedef long long  L;
typedef pair<L, L> pii;
L in,a,a1,a2,a3,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx,mn,flg,flg1,flg2,id1,id2,id3,id4,lim,tm1,st,en,node;
vector<L>V[Mx],B[Mx],V1;
L ans[Mx],vis[Mx];
map<L,L>Mp;
void dfs(L id,L par=-1){
    vis[id]=1;
    node++;
    V1.push_back(id);
    Mp[id]=1;
    L sz=V[id].size();
    for(L i=0;i<sz;i++){
        if(vis[V[id][i]]||par==V[id][i])continue;
        dfs(V[id][i],id);
    }
}
void fun(){
    L lim=V1.size(),id;
    for(L i=0;i<lim;i++){
        id=V1[i];
        L sz=V[id].size();
        d1=node-sz-1;
        sz=B[id].size();
        for(L i=0;i<sz;i++){
            if( Mp[B[id][i]] )d1--;
        }
        ans[id]=d1;
    }
}
void solve(){
    memset(vis,0,sizeof(vis));
    for(L i=1;i<=n;i++){
        if(!vis[i]){
            node=0;
            Mp.clear();
            V1.clear();
            dfs(i);
            fun();
        }
    }
    for(L i=1;i<=n;i++)printf("%lld ",ans[i]);printf("\n");
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(L i=0;i<m;i++){
        scanf("%lld%lld",&u,&v);
        V[u].push_back(v);
        V[v].push_back(u);
    }
    for(L i=0;i<k;i++){
        scanf("%lld%lld",&u,&v);
        B[u].push_back(v);
        B[v].push_back(u);
    }
    solve();
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 129012
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

double calc(int w, int s){
    return 100 * s / double(w + s);
}

int main(void)
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100;
    B *= 100;
    vector<int> ab(F*F, 0);
    for (int i = 0; i < F; i++) {
        for(int j = 0; j < F; j++){
            int a = A*i + B*j;
            if(a <= F){
                ab[i * F + j] = a;
            }else{
                continue;
            }
        }
    }
    vector<int> cd(F*F, 0);
    for (int i = 0; i < F; i++) {
        for(int j = 0; j < F; j++){
            int a = C*i + D*j;
            if(a <= F){
                cd[i * F + j] = a;
            }else{
                continue;
            }
        }
    }

    SORT(ab);
    SORT(cd);
    ab.erase(unique(ALL(ab)), ab.end());
    cd.erase(unique(ALL(cd)), cd.end());
    ab.erase(ab.begin());
    cd.erase(cd.begin());

    int wa = ab[0];
    int sa = 0;
    double va = calc(wa, sa);
    double e = calc(100, E);
    for(auto&& wi : ab){
        for(auto&& si : cd){
            if(wi+si>F)continue;
            double v = calc(wi, si);
            if(v>e) continue;
            if(chmax(va, v)){
                wa = wi;
                sa = si;
            }
        }
    }
    pr(wa+sa, sa);
}

Measured memory_bytes: 65152
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
a = ["a", "b", "c"]
f = 0
g = 0
h = 0
for i in s:
    if i == "a":
        f += 1
    if i == "b":
        g += 1
    if i == "c":
        h += 1

if f == 1 and g == 1 and h == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <stdio.h>
#include <set>

std::set<int> S;

int main()
{
  int t;
  scanf("%d", &t);
  S.insert(t);
  scanf("%d", &t);
  S.insert(t);
  scanf("%d", &t);
  S.insert(t);
  
  printf("%d\n", (int)S.size());
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 100000007
int main()
{
	long long h;
	cin>>h;
	int count=0;
	while(h>=1){
		h/=2;
		count++;
	}


	long long  ans= (long long) pow(2,count)-1 ;
	cout<<ans;
	
	

}

Measured memory_bytes: 256
object Main extends App {

  val n = scala.io.StdIn.readInt()
  val s = scala.io.StdIn.readLine()


  def solve() =  {
    val defaultChar: Char = ' '
    s.foldLeft((0, defaultChar)) { case ((cnt, prevChar), char) =>
      if(char != prevChar) (cnt + 1, char)
      else (cnt, char)
    }._1
  }

  println(solve)

}

Measured memory_bytes: 33120
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        ArrayList<ArrayList<Integer>> children = new ArrayList<>(N);
        for(int i = 0 ; i < N ; i++){
            children.add(new ArrayList<Integer>());
        }

        for(int i = 0 ; i < M ; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;

            children.get(a).add(b);
            children.get(b).add(a);
        }

        LinkedList<Integer> queue = new LinkedList<>();
        queue.add(0);
        int[] arrow = new int[N];
        for(int i = 0 ; i < N ; i++){
            arrow[i] = -1;
        }
        arrow[0] = 0;
        while(!queue.isEmpty()){
            int now = queue.removeFirst();
            for(int next : children.get(now)){
                if(arrow[next] == -1){
                    queue.addLast(next);
                    arrow[next] = now+1;
                }
            }
        }

        StringBuilder strb = new StringBuilder("Yes\n");
        for(int i = 1 ; i < N ; i++){
            strb.append(arrow[i]);
            strb.append("\n");
        }
        System.out.println(strb.toString());
    }
}


Measured memory_bytes: 76408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next() + sc.next();
        double num = Double.parseDouble(s);
        int root = (int)Math.sqrt(num);

        System.out.println(num == Math.pow(root, 2) ?  "Yes" : "No");
    }
}


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

using namespace std;

struct JOI {
    int j;
    int o;
    int i;
    void setval(int x, int y, int z) {
        j=x;
        o=y;
        i=z;
    }
    JOI operator+(JOI a);
    JOI operator-(JOI a);
};

JOI JOI::operator+(JOI a) {
    JOI temp;
    temp.j=j+a.j;
    temp.o=o+a.o;
    temp.i=i+a.i;
    return temp;
}

JOI JOI::operator-(JOI a) {
    JOI temp;
    temp.j=j-a.j;
    temp.o=o-a.o;
    temp.i=i-a.i;
    return temp;
}

int main()
{
    int M,N,K;
    string instr;

    cin >> M >> N >> K;

    JOI joi[M+1][N+1];

    for(int i=0; i<=M; ++i) {
        joi[i][0].setval(0,0,0);
    }
    for(int j=0; j<=N; ++j) {
        joi[0][j].setval(0,0,0);
    }

    for(int i=1; i<=M; ++i) {
        JOI temp,temp2;

        cin >> instr;

        temp.setval(0,0,0);
        for(int j=1; j<=N; ++j) {
            if(instr[j-1]=='J') {
                temp2.setval(1,0,0);
            } else if(instr[j-1]=='O') {
                temp2.setval(0,1,0);
            } else {
                temp2.setval(0,0,1);
            }
            temp=temp+temp2;
            joi[i][j]=joi[i-1][j]+temp;
        }
    }

    for(int i=0; i<K; ++i) {
        int a,b,c,d;

        cin >> a >> b >> c >> d;

        JOI ans=joi[c][d]-joi[c][b-1]-joi[a-1][d]+joi[a-1][b-1];

        cout << ans.j << " " << ans.o << " " << ans.i << endl;
    }

    return 0;
}

Measured memory_bytes: 14784
#include <stdio.h>

int horieyui(int a, int b) {
	while (b > 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int N;
int A[114514];

int main(void) {
	int i;
	int nakagawasyouko;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	nakagawasyouko = A[0];
	for (i = 1; i < N; i++) {
		nakagawasyouko = horieyui(nakagawasyouko, A[i]);
	}
	printf("%d\n", nakagawasyouko);
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const i64 INFT = 1LL << 60LL;

int N;
i64 H[5050], P[5050];

i64 dp[5050][5050];

void chmin(i64& a, i64 b) { a = min(a, b); }

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld%lld", H + i, P + i);

	vector<pair<i64, pair<i64, i64> > > ppl;
	for (int i = 0; i < N; ++i) ppl.push_back({ H[i] + P[i], {H[i], P[i]} });
	sort(ppl.begin(), ppl.end());

	for (int i = 0; i < N; ++i) {
		H[i] = ppl[i].second.first;
		P[i] = ppl[i].second.second;
	}

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) dp[i][j] = INFT;
	}
	dp[0][0] = 0;

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= i; ++j) {
			chmin(dp[i + 1][j], dp[i][j]);
			if (dp[i][j] <= H[i]) chmin(dp[i + 1][j + 1], dp[i][j] + P[i]);
		}
	}

	for (int i = N; i >= 0; --i) {
		if (dp[N][i] < (1LL << 40LL)) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 199360
//ABC154D.cpp
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric> //accumulateに必要
#include <iomanip> //setprecision(桁数指定)に必要
using namespace std;

int main(){
	int N,K;
	cin>>N>>K;
	vector<float> p;
	for(int i=0;i<N;i++){
		float a;
		cin>>a;
		a = (a+1)/2;
		p.push_back(a);
	}
	long double sum = accumulate(p.begin(),p.begin()+K,0.0);
	long double out = sum;
	for(int i=1;i<N-K+1;i++){
		sum-=p[i-1];
		sum+=p[i+K-1];
		if(out<sum)out=sum;
	}
	cout<<setprecision(10)<<out<<endl;
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll x,y,a,b,c,ans=0;
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
    ll p[a],q[b],r[c];
    rep(i,0,a){
        scanf("%lld",&p[i]);
    }
    rep(i,0,b){
        scanf("%lld",&q[i]);
    }
    rep(i,0,c){
        scanf("%lld",&r[i]);
    }
    sortdown(p,a);
    sortdown(q,b);
    sortdown(r,c);
    ll w= c>=x+y ? (x+y)*2 : x+y+c , z[w];
    rep(i,0,x){
        z[i] = p[i];
    }
    rep(i,0,y){
        z[i+x] = q[i];
    }
    rep(i,0,w-(x+y)){
        z[i+x+y] = r[i];
    }
    sortdown(z,w);
    rep(i,0,x+y){
        ans+=z[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 7660
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  intlist, err := SplitIntStdin(" ")
  if err == nil {
    leftweight := intlist[0] + intlist[1]
    rightweight := intlist[2] + intlist[3]
    
    if leftweight > rightweight {
      fmt.Println("Left")
    }else if leftweight < rightweight {
      fmt.Println("Right")
    }else{
      fmt.Println("Balanced")
    }
  }
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


void ans(bool flag) {
  if (flag) printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
  exit(0);
}

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

int main(){
  int n, k;
  scanf("%d %d", &n, &k);

  vector<int> v(n);
  REP (i, n) {
    scanf("%d", &v[i]);
  }

  sort(v.begin(), v.end());
  if (k == *lower_bound(v.begin(), v.end(), k)) ans(true);
  else if (v[n - 1] < k) ans(false);
  else {
    int x = v[0];
    REP (i, n) {
      x = gcd(x, v[i]);
    }
    if (k % x == 0) ans(true);
    else ans(false);
  }
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

R,C,K=map(int,input().split())
V=[[0]*C for _ in range(R)]
for i in range(K):
    r,c,v=map(int,input().split())
    r-=1
    c-=1
    V[r][c]=v
dp=[[0]*C for _ in range(4)]
for y in range(R):
    for x in range(C):
        for i in range(2,-1,-1):
            dp[i+1][x]=max(dp[i+1][x],dp[i][x]+V[y][x])
        if x<C-1:
            for i in range(3,-1,-1):
                dp[i][x+1]=max(dp[i][x+1],dp[i][x])
    if y+1<R:
        MAX=0
        for x in range(C):
            for i in range(4):
                MAX=max(MAX,dp[i][x])
                dp[i][x]=0
            dp[0][x]=MAX
print(max(dp[0][-1],dp[1][-1],dp[2][-1],dp[3][-1]))

Measured memory_bytes: 145904
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (bs (make-array n :element-type 'uint7))
         (marked (make-array n :element-type 'boolean :initial-element nil))
         (cumul (make-array n :element-type 'uint7 :initial-element 0))
         res)
    (dotimes (i n) (setf (aref bs i) (- (read) 1)))
    (dotimes (time n)
      (loop for i from (- n 1) downto 0
            do (when (and (not (aref marked i))
                          (= (aref bs i) (aref cumul i)))
                 (push (aref bs i) res)
                 (setf (aref marked i) t)
                 (loop for j from (1+ i) below n
                       do (incf (aref cumul j)))
                 (return))
            finally (println -1)
                    (return-from main)))
    (dolist (b (reverse res))
      (println (1+ b)))))

#-swank(main)


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

int n, u, m = 0;
string s;

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

	for (int i = 1; i < n; i++) {
		u = 0;
		for (int j = 0; j < n - i; j++) {
			if (s[i + j] == s[j] && u < i)
				u++;
			else{
				m = max(m, u);
				u = 0;
			}
		}

		m = max(m, u);
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define pii tuple<ll,ll,ll>
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
int x;
cin>>x;
if (x>=30)
    cout<<"Yes";
else
    cout<<"No";


}


Measured memory_bytes: 3640
// -_-
#include <bits/stdc++.h>
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
#define  sort1(v) sort(v.begin(), v.end()) 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
 
 
signed main() 
{
 
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	read(n);
	readarr(a, n);
	int dp[n+1][n+1][3];
 
	int sum[n+1];
	sum[0] = 0;
	fori(i, 1, n) sum[i] = sum[i-1]+a[i];
 
	fori(i, 1, n-1)
	{
		fori(j, 1, n-i)
		{
			int k = j+i;
			if(k-j == 1) {dp[j][k][1] = max(a[j], a[k]); dp[j][k][2] = min(a[j], a[k]);}
			else
			{
				dp[j][k][1] = max(a[j] + dp[j+1][k][2], a[k] + dp[j][k-1][2]);
				dp[j][k][2] = (sum[k] - sum[j-1]) - dp[j][k][1];
			}
		}
	}
	if(n == 1) cout << a[1];
	else 
	cout << dp[1][n][1]-dp[1][n][2];
	return 0;
}


Measured memory_bytes: 210688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    int p[20];
    rep(i, n) cin >> p[i];

    int cnt = 0;
    Rep(i, 1, n - 1)
    {
        int tmp1 = min(p[i - 1], p[i]);
        int tmp2 = min(p[i], p[i + 1]);
        if (tmp1 != tmp2 && p[i] == max(tmp1, tmp2))
        {
            //COUT(p[i]);
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def factorial(x):
    if x > 1:
        return factorial(x-1) * x
    else:
        return 1

def remained(num, remain_list):
    return sum([item < num for item in remain_list])

order_p, order_q = 1, 1
remain_p, remain_q = list(range(1, N+1)), list(range(1, N+1))

for i in range(N-1):
    order_p += remained(p[i], remain_p) * factorial(N - i - 1)
    order_q += remained(q[i], remain_q) * factorial(N - i - 1)
    remain_p.remove(p[i])
    remain_q.remove(q[i])

print((order_p - order_q) if (order_p - order_q > 0) else (order_q - order_p))

Measured memory_bytes: 3064
import string

s = list(input())
k = int(input())
d = {c:(26-i)%26 for i, c in enumerate(string.ascii_lowercase)}
d_inv = {(26-i)%26:c for i, c in enumerate(string.ascii_lowercase)}

for i in range(len(s)):
    if k > 0:
        if d[s[i]] <= k:
            k -= d[s[i]]
            s[i] = "a"
    else:
        break
s[-1] = d_inv[(d[s[-1]]-k)%26]

print("".join(s))

Measured memory_bytes: 4796
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

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


template <typename T>
class CoodinateCompression {
 public:
  CoodinateCompression(const std::vector<T>& vec) : vec_(vec) {
    result_.resize(vec_.size());
    Compress();
  }
  struct state {
    T before;
    int after;
  };
  state operator[](const int& pos) const;

 private:
  std::vector<T> vec_;
  std::vector<state> result_;
  void Compress();
};

template <typename T>
typename CoodinateCompression<T>::state CoodinateCompression<T>::operator[](
    const int& pos) const {
  return result_[pos];
}

template <typename T>
void CoodinateCompression<T>::Compress() {
  std::vector<T> t = vec_;
  std::sort(t.begin(), t.end());
  t.erase(std::unique(t.begin(), t.end()), t.end());
  for (size_t i = 0; i < vec_.size(); ++i) {
    result_[i] = {vec_[i], static_cast<int>(std::distance(
                               t.begin(),
                               std::lower_bound(t.begin(), t.end(), vec_[i])))};
  }
}

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

  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  CoodinateCompression<int> cc(a);
  int cnt = 0;
  for (int i = 0; i < n; i += 2) {
    if (cc[i].after & 1) {
      ++cnt;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 2176
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int count = 0;
        String Y[] = new String[5];
        
        for(int i=A; i<=B; i++){
            if(i/10000==i%10&&(i/1000)%10==(i/10)%10)
            count++;
        }

        System.out.println(count);

        }
    }    





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

int main()
{
    string s;

    cin >> s;

    if(s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}

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

#define MAX 1000000



int main(void){

	bool p[MAX+1];
	int n,ans;

	for(int i=0;i<=MAX;i++){
		p[i]=(i<=1)?false:true;
	}

	for(int i=2;i<=(sqrt((double)MAX))+1;i++){
		if(p[i]){
			for(int j=i*2;j<=MAX;j=j+i){
				p[j]=false;
			}
		}
	}

	while(cin>>n){
		ans=0;
		for(int i=0;i<=n;i++){
			if(p[i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define sz(c) int((c).size())

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
   int n; cin >> n;
   set<string> S;
   char c;
   string s;
   for(int i = 0; i < n; i++) {
   	if (i) c = s[s.size() - 1];
   	cin >> s;
   	if(S.count(s) || (i > 0 && c != s[0])) {
   		cout << "No" << endl;
   		return 0;
   	}
   	S.insert(s);
   }
   cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N;
    int p;
    int i, j;
    int ans = 0;
    int pmin = MOD;

    cin >> N;

    rep(i, 0, N - 1)
    {
        cin >> p;

        if (pmin > p)
        {
            pmin = p;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC120_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = int.Parse(input[0]);
            var B = int.Parse(input[1]);
            var K = int.Parse(input[2]);

            var commonDivisor = new List<int>(); //AとBの公約数リスト
            commonDivisor.Add(1);
            var checkCount = Math.Max(A, B);
            for (int i = 2; i <= checkCount; i++)
            {
                if (A % i == 0 && B % i == 0)
                {
                    commonDivisor.Add(i);
                }
            }
            Console.WriteLine(commonDivisor[commonDivisor.Count - K]);
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n+1) { } 
  void add(int k, T a) { 
    for (++k; k < x.size(); k += k&-k) x[k] += a;
  }
  T sum(int k) {
    T s = 0;
    for (; k > 0; k &= k-1) s += x[k];
    return s;
  }
  T sum(int a, int b) {
    return sum(b) - sum(a);
  }
};


int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  int Q;
  while (cin >> N >> S >> Q) {
    vector<int> X(N);
    for (int i = 0; i < N; i++) X[i] = S[i] - 'a';
    vector<fenwick_tree<int>> bits(26, fenwick_tree<int>(N));
    for (int i = 0; i < N; i++) {
      bits[X[i]].add(i, 1);
    }
    for (int q = 0; q < Q; q++) {
      int type;
      cin >> type;
      if (type == 1) {
        int i;
        char c;
        cin >> i >> c;
        --i;
        bits[X[i]].add(i, -1);
        X[i] = c - 'a';
        bits[X[i]].add(i, +1);
      } else {
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        int sum = 0;
        for (int c = 0; c < 26; c++) sum += bits[c].sum(l, r + 1) > 0;
        cout << sum << endl;
      }
    }
  }
  return 0;
}


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

int main(){
int N,M;
  cin>>N>>M;
  
  vector<int>a(M);
  vector<int>b(M);
  vector<int>S(N);
  for(int i=0; i<M; i++){
   cin>>a[i]>>b[i]; 
    S[a[i]-1]++;
    S[b[i]-1]++; 
  }
  
  for(int i=0; i<N; i++){
   cout<<S[i]<<endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll x; cin>>x;
    ll a = x/11;
    if(x%11==0) cout<<2*a<<endl;
    else if(x%11<=6) cout<<2*a+1<<endl;
    else cout<<2*a+2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<int> a(n), s;
	rep(i,n) cin >> a[i];
	s = a;
	sort(all(s));

	int cnt = 0;
	rep(i,n){
		if(distance(s.begin(), lower_bound(all(s), a[i])) % 2 != i % 2) cnt++;
	}
	cout << cnt / 2 << endl;
}


Measured memory_bytes: 1024