akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//SUN, MON, TUE, WED, THU, FRI, or SAT.
int func(string st)
{if(st=="SUN") return 7;
 else if(st=="MON")return 6;
 else if(st=="TUE")return 5;
 else if(st=="WED")return 4;
 else if(st=="THU")return 3;
 else if(st=="FRI")return 2;
 else if(st=="SAT") return 1;
}
int main()
{
  string st;cin>>st;
  cout<<func(st);
return 0;
}

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

const int maxN = 100100;
bool visited[maxN];
vector<int> adj[maxN];

void dfs(int node) {
	visited[node] = true;
	for (auto child : adj[node]) {
		if (!visited[child]) {
			dfs(child);
		}
	}
}
int main () {
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 //~ cin >> T;
	 for (int t = 1; t <= T; ++t) {
		 int n,m;
		 cin >> n >> m;
		 for (int i = 1; i <= m; ++i) {
			 int u,v;
			 cin >> u >> v;
			 adj[u].push_back(v);
			 adj[v].push_back(u);
		 }
		 dfs(1);
		 int count = 0;
		 for (int i = 1; i <= n; ++i) {
			 if (!visited[i]) {
				 dfs(i);
				 count += 1;
			 }
		 }
		 cout << count << "\n";
	 }
}


Measured memory_bytes: 9668
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,i,j,t[1005],sum,p,xx,x,m;
    while(cin>>n)
    {
        sum=0;
        for(i=1;i<=n;i++)
        {
            cin>>t[i];
            sum+=t[i];

        }
        xx=sum;
        cin>>m;
        for(i=1;i<=m;i++)
        {
            sum=xx;
            //cout<<sum<<endl;
            cin>>p>>x;
            sum=sum-t[p];
            sum+=x;
            cout<<sum<<endl;

        }
        return 0;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

void line1(int W){
    for(W;W>0;W--)
        putchar('#');
    
    putchar('\n');
}

void line2(int W){
    putchar('#');

    W = W-2;
   for(W;W>0;W--)
        putchar('.');
   printf("#\n");
}


int main(){
    while(1){
    int W,H;
    scanf("%d %d", &H,&W);
    if(W==0 && H==0)break;

    line1(W);
    
    int h = H-2;
    for(h;h>0;h--)
        line2(W);

    line1(W);
    putchar('\n');
    }

    return 0;

}


Measured memory_bytes: 2016
N = int(input())
S = input()
ans = 0
for d in range(1, N):
    count = 0
    for i in range(N-d):
        if S[i] == S[i+d]:
            count += 1
        else:
            count = 0
        ans = max(min(count, d), ans)
print(ans)


Measured memory_bytes: 42476
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 300 + 9, M = 100 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

double p[N][N][N], ev[N][N][N];
int n, x, cnt[4];

int main() {
//	INPUT();
	OUTPUT();
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		cnt[x]++;
	}
	p[cnt[1]][cnt[2]][cnt[3]] = 1;
	for (int c = n; c >= 0; --c) {
		for (int b = n; b >= 0; --b) {
			for (int a = n; a >= 0; --a) {
				if (a == 0 && b == 0 && c == 0)
					continue;
				if (a + b + c > n)
					continue;
				double p_waste = (double) (n - (a + b + c)) / n;
				double ev_waste = p_waste / (1 - p_waste) + 1;
				ev[a][b][c] += ev_waste * p[a][b][c];
				if (a != 0) {
					double p_go = (double) a / (a + b + c);
					p[a - 1][b][c] += p[a][b][c] * p_go;
					ev[a - 1][b][c] += ev[a][b][c] * p_go;
				}
				if (b != 0) {
					double p_go = (double) b / (a + b + c);
					p[a + 1][b - 1][c] += p[a][b][c] * p_go;
					ev[a + 1][b - 1][c] += ev[a][b][c] * p_go;
				}

				if (c != 0) {
					double p_go = (double) c / (a + b + c);
					p[a][b + 1][c - 1] += p[a][b][c] * p_go;
					ev[a][b + 1][c - 1] += ev[a][b][c] * p_go;
				}
			}
		}
	}
	cout << ev[0][0][0];

	return 0;

}


Measured memory_bytes: 450816
#include <iostream>

using namespace std;


int main() {

	int n, card1[200], card2[200], m, sousa[1000];

	cin >> n >> m;

	for (int a = 0; a < m; a++)
		cin >> sousa[a];

	for (int c = 0; c < 2 * n; c++) {

		card1[c] = c + 1;

		card2[c] = c + 1;

	}

	for (int i = 0; i < m; i++) {

		if (sousa[i] == 0) { //??????i?????????0?????£??????//

			for (int j = 0; j < 2 * n; j++) {

				if (j % 2 == 0) { //?????????????\???°???????????????//

					card2[j] = card1[j / 2];

				}
				else {//??????????????¶??°???????????????//

					card2[j] = card1[n + ( (j - 1) / 2 )];

				}

			}

			for (int j = 0; j < 2 * n; j++) card1[j] = card2[j];

		}
		else if (0 < sousa[i] && sousa[i] < 2 * n) {

			for (int j = 0; j < 2 * n; j++) {

				if (j < 2 * n - sousa[i]) card2[j] = card1[j + sousa[i]];

				else card2[j] = card1[j - (2 * n - sousa[i])];

			}
			for (int j = 0; j < 2 * n; j++) card1[j] = card2[j];

		}

	}

	for (int b = 0; b < 2 * n; b++) cout << card1[b] << "\n";
	return 0;
}

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

public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringBuilder out = new StringBuilder();

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
	int N = Integer.parseInt(br.readLine());	
	String[] in = br.readLine().split(" ");
	cards[] cds_b = new cards[N];
	cards[] cds_s = new cards[N];
	for(int i = 0; i<N;i++){
		cds_b[i] = new cards(in[i]);
		cds_s[i] = new cards(in[i]);
	}
	
	cards tmp;
	for(int i = 0; i<cds_b.length;i++){
		for(int j=cds_b.length-1;j>i;j--){
			if(cds_b[j].num < cds_b[j-1].num){
				tmp = cds_b[j-1];
				cds_b[j-1] = cds_b[j];
				cds_b[j] = tmp;
			}
		}
	}
	
	for(int i=0; i<N;i++){
		if(i>0)
			System.out.print(" ");
		System.out.print(cds_b[i].tp);
	}
	System.out.print("\n");
	System.out.println("Stable");

	int mini;

	for(int i = 0; i<N; i++){
		mini=i;
		for(int j = i;j<N;++j){
			if(cds_s[mini].num> cds_s[j].num){
				mini=j;
			}
		}
		if(i != mini){
			tmp=cds_s[i];
			cds_s[i]=cds_s[mini];
			cds_s[mini]=tmp;
		}
	}
	
	boolean flg=true;
	for(int i=0;i<N;i++){
		if(cds_b[i].tp !=cds_s[i].tp)
			flg=false;
	}
	
	for(int i=0; i<N;i++){
		if(i>0)
			System.out.print(" ");
		System.out.print(cds_s[i].tp);
	}
	System.out.print("\n");
	if(flg==true)
		System.out.println("Stable");
	else
		System.out.println("Not stable");
		

	}
	


}

class cards{
	String mark;
	int num;
	String tp;
	cards(String in){
		this.tp=in;
		this.mark = in.substring(0,1);
		this.num = Integer.parseInt(in.substring(1,2));
	}
}

Measured memory_bytes: 24236
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	final int J = 10;
	int dp[][];
	int bv[][];
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		@SuppressWarnings("unchecked")
		LinkedList<Integer>[] books = new LinkedList[J];
		for(int i=0;i<J;i++) books[i] = new LinkedList<Integer>();
		for(int i=0;i<n;i++) {
			int c = sc.nextInt();
			int g = sc.nextInt()-1;
			books[g].add(c);
		}
		bv = new int[J][];
		for(int i=0;i<J;i++) bv[i] = new int[books[i].size()+1];
		for(int i=0;i<J;i++) {
			Collections.sort(books[i]);
			int size = books[i].size();
			for(int j=1;j<=size;j++) {
//				debug(books[i]);
				bv[i][j] = books[i].removeLast() + bv[i][j-1];
			}
			for(int j=1;j<=size;j++) {
				bv[i][j] += j * (j-1);
			}
		}
		dp = new int[J][k+1];
		for(int[] a: dp) fill(a, -1);
		System.out.println(solve(0, k));
//		debug(bv);
//		for()
	}
	
	int solve(int j, int k) {
		if(j == 10) return 0;
		if(dp[j][k] >= 0) return dp[j][k];
		
		int ret = 0;
		int kk = min(k, bv[j].length-1);
		for(int i=0;i<=kk;i++) {
			ret = max(ret, bv[j][i] + solve(j+1, k-i));
		}
		
		return dp[j][k] = ret;
	}
	
	
	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
long long N;
int main() {
    cin >> N;
    vector<long long> L(N+1, 0);
    L.at(0) = 2; L.at(1) = 1;
    if(N == 0) {
        cout << 2 << endl;
    }else if(N == 1) {
        cout << 1 << endl;
    }else {
        for(int i = 2; i < N+1; ++i) {
            L.at(i) = L.at(i-1) + L.at(i-2);
        }
        cout << L.at(N) << endl;
    }
}

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

ans = 0
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n = inp()
S = input()
ans_string = ''

for i in range(len(S)):
    ans_string += alphabet[(alphabet.index(S[i])+n)%26]
print(ans_string)

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k, n, i, ans = 0;
	cin >> k >> n;
	int a[n + 3];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
    for(i=0;i<n-1;i++)
    {
    	ans=max(ans,abs(a[i]-a[i+1]));
    }
    ans=max(ans,k-a[n-1]+a[0]);
    cout<<(k-ans)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}

int convexCut(int n, Pt p[], Pt a, Pt b, Pt q[]) {
	int m = 0, i;
	p[n] = p[0];
	for (i = 0; i < n; ++i) {
		if (sig(tri(a, b, p[i])) >= 0) q[m++] = p[i];
		if (sig(tri(a, b, p[i])) * sig(tri(a, b, p[i + 1])) < 0) q[m++] = pLL(a, b, p[i], p[i + 1]);
	}
	q[m] = q[0];
	return m;
}
Pt p[110];
Pt res[210];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		double S=(double)c/b;
		for(int i=0;i<a;i++){
			double X,Y;
			scanf("%lf%lf",&X,&Y);
			p[i]=Pt(X,Y);
		}
		double ret=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				if(i!=j)p[j]=p[j]-p[i];
			}
			p[i]=Pt(0,0);
			double th=p[(i+1)%a].arg();
			for(int j=0;j<a;j++){
				p[j]=p[j]*Pt(cos(-th),sin(-th));
			}
			double L=0;
			double R=0;
			for(int j=0;j<a;j++)R=max(R,p[j].y);
			for(int j=0;j<100;j++){
				double M=(L+R)/2;
				int m=convexCut(a,p,Pt(1000,M),Pt(-1000,M),res);
				double tmp=0;
				for(int k=0;k<m;k++)tmp+=res[k].det(res[(k+1)%m]);
				if(tmp<0)tmp=-tmp;
				tmp/=2;
			//	printf("%f: %f\n",M,tmp);
				if(tmp>S)R=M;
				else L=M;
			}
	//		printf("%d: %f\n",i,L);
			ret=max(ret,L);
		}
		printf("%.12f\n",ret);
	}
}

Measured memory_bytes: 1188
N = int(input())

def primes(n):
    a = []
    for i in range(1, n+1):
        if n % i == 0:
            a.append(i)
    return a

k = 0
for i in range(N+1):
    if i % 2 == 1:
        if len(primes(i)) == 8:
            k += 1
print(k)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
//Unionfind
int n, q, a[123456], b, c, s;
signed main() {
	cin >> n; for1(i, n)a[input()]++;
	for1(i, 100000)s += i * a[i];
	cin >> q;
	for1(i, q) {
		cin >> b >> c; s += (c - b) * a[b];
		a[c] += a[b]; a[b] = 0;
		puts(s);
	}
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll n = s.size();
    string t ="";
    ll ans = 0;
    if(n >= 2){
        for(ll i=0; i<n-1; i++){
            if(s[i] == 'B' && s[i+1] == 'C'){
                t += "Z";
                i++;
            }
            else t += s[i];
        }
        n = t.size();
        ll aCnt = 0;
        rep(i, n){
            if(t[i] == 'Z') ans += aCnt;
            else if(t[i] == 'A')  aCnt++;
            else aCnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3876
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int IsPrime(int n){
    int i;
 
    if(n < 2)
        return 0;
    else if(n == 2)
        return 1;
 
    if(n % 2 == 0)
        return 0;
 
    for(i = 3; i <= n / i; i += 2)
         if(n % i == 0)
            return 0;
    return 1;
}

int main (){
int a,b,c,d=0,e,f=0,g;
int sosu[1000000]={};
int kaisu[100];
for(b=2;b<1000000;b++){
	if(IsPrime(b)==1)d++;
	sosu[b]=d;
}
while(scanf("%d",&a)!=EOF){
	kaisu[f]=sosu[a];

	f++;
	
}
for(e=0;e<f;e++)
printf("%d\n",kaisu[e]);
}

Measured memory_bytes: 4512
#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 FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  map<int,int> mp;
  REP(i,3){
    int x;
    cin >> x;
    mp[x]++;
  }

  puts((mp[5]==2&&mp[7]==1 ? "YES" : "NO"));
  return 0;
}

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

const int INF = 1 << 29;
int N, K;
int A[101010];
int B[101010];
int C[101010];

bool check(int len) {
    if (len == 1) {
        return true;
    }
    REP(i, N-len+1) {
        int l = i;
        int r = i + len - 1;
        int ones = C[r] - C[l];
        int cnt = 0;
        
        if (A[l] == A[r] && A[l] == 0) {
            cnt = 1 + ones / 2;
        } else if (A[i] == A[r] && A[l] == 1) {
            cnt = ones / 2;
        } else {
            cnt = 1 + ones / 2;
        }

        if (cnt <= K) return true;
    }
    return false;
}

void solve() {
    cin >> N >> K;
    string S; cin >> S;
    REP(i, N) A[i] = S[i] == '1';
    REP(i, N-1) B[i] = A[i] ^ A[i+1];
    REP(i, N) C[i+1] = C[i] + B[i];

    int hi = N + 1;
    int lo = 1;
    while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        (check(mid) ? lo : hi) = mid;
    }

    cout << lo << endl;
}   

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

Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,k,tot,head[N],nex[N<<1],to[N<<1],son[N];
bool flag;
ll ans,f[N],invf[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll c(ll n,ll m)
{
    if(n<m) return 0;
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
}
void dfs1(int u,int fa)
{
    for(int i=head[u];i;i=nex[i])
        if(to[i]!=fa)
        dfs1(to[i],u),son[u]++;
    int sum=k-2;
    if(u==1) sum++;
    ans=ans*f[son[u]]%mod*c(sum,son[u])%mod;
}
int main()
{
    f[0]=invf[0]=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=max(n,k);i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    ans=k;
    dfs1(1,0);
    if(flag) printf("0\n");
    else printf("%lld\n",ans);
}


Measured memory_bytes: 7680
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a:i32,
        op:chars,
        b:i32,
    }
    if op[0] == '+' {
        println!("{}", a + b);
    } else {
        println!("{}", a - b);
    }
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main(){
    string s;
    int x;
    int min = -1;
    int i,j;
    cin >> s;
    for(i=0;i<s.size() - 2;i++){
        x = 0;
        for(j=0;j<3;j++){
            x *= 10;
            x += s[i+j] - '0';
        }
        x = abs(x - 753);
        if( min < 0 || x < min){
            min = x;
        }
    }
    cout << min << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <utility>
#define N 120
using namespace std;

pair<int, int> a[N];

int main(void)
{
    int n;
    int i, k, x, y;
    long long o;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d %d", &a[i].first, &a[i].second);

    for(k = o = 0; k < 100000; k ++)
    {
        random_shuffle(a, a + n);
        x = y = 0;
        for(i = 0; i < n; i ++) {
            if((long long)(x + a[i].first) * (x + a[i].first) + (long long)(y + a[i].second) * (y + a[i].second) > (long long)x * x + (long long)y * y)
            {
                x += a[i].first ;
                y += a[i].second;
            }
        }
        o = max(o, (long long)x * x + (long long)y * y);
    }
    printf("%.15Lf\n", sqrt((long double)o));

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n;

int main(){
  ll ans=0;
  cin >> n;

  vi dp(100001);
  dp[0]=1;


  for(int i=1;i<100001;i++){
    if (i>=100){
      if (dp[i-100]==1)dp[i]=1;
    }
    if (i>=101){
      if (dp[i-101]==1)dp[i]=1;
    }
    if (i>=102){
    if (dp[i-102]==1)dp[i]=1;
    }
    if (i>=103){
    if (dp[i-103]==1)dp[i]=1;
    }
    if (i>=104){
    if (dp[i-104]==1)dp[i]=1;
    }
    if (i>=105){
    if (dp[i-105]==1)dp[i]=1;
    }
  }
  
  cout<<dp[n]<<endl;
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/01/27  Problem: nikkei_2019_qual D / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N, M; cin >> N >> M;
	VVI G(N);
	VI indeg(N+1, 0);
	FOR(i, 0, N + M - 1) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		indeg[b]++;
	}

	/*VI di(N + 1, INF);
	priority_queue<PII, vector<PII>,greater<PII>>pq;
	FOR(i, 1, N+1) {
		if (indeg[i] == 0) {
			pq.push(PII(0,i));
			di[i] = 0;
			DD(de(i));
		}
	}
	VI par(N+1, 0);
	while (!pq.empty()) {
		int d, v;
		tie(d, v) = pq.top(); pq.pop();
		if(d!= di[v])continue;
		for (auto nx : G[v]) {
			if (d - 1 < di[nx]) {
				di[nx] = d - 1;
				par[nx] = v;
				DD(de(nx, v));
				pq.push(PII(d - 1, nx));
			}
		}
	}
*/

	auto f = [](const VVI&g) {
		int n = (int)g.size(), k = 0;
		vector<int> ord(n, 0), in(n, 0);
		for (int i = 0; i < (int)g.size(); i++)
			for (int j = 0; j < (int)g[i].size(); j++)
				in[g[i][j]]++;

		queue<int> q;
		for (int i = 0; i < n; ++i)
			if (in[i] == 0) q.push(i);

		while (q.size()) {
			int v = q.front(); q.pop();
			ord[k++] = v;
			for (int i = 0; i < (int)g[v].size(); i++)
				if (--in[g[v][i]] == 0) q.push(g[v][i]);
		}
		return ord;
	};

	auto c = f(G);
	VI par(N, 0);
	VI di(N, 0);
	for (int id : c) {
		for (int nx : G[id]) {
			if (di[nx] < di[id] + 1) {
				di[nx] = di[id] + 1;
				par[nx] = id;
			}
		}
	}

	FOR(i, 1, N+1) {
		if (c[0] == i-1)cout << 0 << endl;
		else cout << par[i-1]+1 << endl;
	}





	return 0;
}


Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  bool t=true;
  cin >> n;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a%2==0){
      if(a%3==0 || a%5==0)continue;
      else{
        cout << "DENIED" << endl;
        t=false;
        break;
      }
    }
  }
  if(t)cout << "APPROVED" << endl;
}

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

int main() {
  int n,ans=0; cin>>n;
  vector<int> a(n+1),b(n+1);
  a[0]=0; b[0]=0;
  for(int i=1; i<=n; i++) {
    int x; cin>>x;
    a[i] += a[i-1]+x;
  }
  for(int i=1; i<=n; i++) {
    int x; cin>>x;
    b[i] += b[i-1]+x;
  }
  for(int i=1; i<=n; i++) {
    ans = max(ans,a[i]-a[0]+b[n]-b[i-1]);
  }
  cout<<ans;
}


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

int main(void)
{
    int n;
    cin >> n;
    long long int min = 10000000;
    long long int max = -10000000;
    long long int x,sum = 0;
    
    for(int i = 0; i < n; i++){
        cin >> x;
        if(min > x){
            min = x;
        }
        if(max < x){
            max = x;
        }
        sum = sum + x;
    }
    cout << min << " ";
    cout << max << " ";
    cout << sum << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int H, N;
int A[1000], B[1000];
int dp[10001];

int main(void){
	cin >> H >> N;
	for(int i = 0; i < N; i++) cin >> A[i] >> B[i];

	for(int i = 0; i <= H; i++) dp[i] = INF;
	dp[0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= H; j++){
			if(j+A[i] >= H) dp[H] = min(dp[H], dp[j] + B[i]);
			else dp[j+A[i]] = min(dp[j+A[i]], dp[j] + B[i]);
			// printf("dp(%d, %d) = %d\n", i, j, dp[j]);
		}
	}

	cout << dp[H] << '\n';

	return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let nk: Vec<i32> = read_vec();
    let an: Vec<i32> = read_vec();
    let mut m : HashMap<i32,i32>= HashMap::new();
    for x in an {
        let ins_value = match m.get(&x) {
            Some(y) => y + 1,
            None => 1,
        };
        m.insert(x,ins_value);
    }
    let mut v:Vec<(&i32,&i32)> = m.iter().collect();
    v.sort_by(|&(_, a), &(_, b)| b.cmp(&a));
    let ans = run(&mut v,nk[1],0);
    println!("{}",ans);
}
fn run(v:&mut Vec<(&i32,&i32)>,k:i32,count:i32) -> i32 {
    if v.len() > k as usize {
        let (_,x) = v.pop().unwrap();
        run(v , k , count + x)
    } else {
       count
    }
}

Measured memory_bytes: 13328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら降順)
    return *((int*)b)- *((int*)a);
}

int main(){
    int N;
    int p[50],sample[50];

    for(int i=0;i<50;i++){
        sample[i]=i+1;
    }
    scanf("%d%*c",&N);
    InputIntAry(p,3,N);

    int cnt=0;
    for(int i=0;i<N;i++){
        if(sample[i] != p[i])
            cnt++;
    }
    if(cnt == 0 || cnt == 2){
        puts("YES");
    }
    else{
        puts("NO");
    }

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=20000;
const ll MOD=17;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
const int offset=5000;
bool ab[MAXN];
bool ac[MAXN];
bool bc[MAXN];
bool legal(char c1,char c2){
    return c1=='?'||c2=='?'||c1==c2;
}
void solve(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b,c;
    cin>>a>>b>>c;
    int na=a.size(),
    nb=b.size(),
    nc=c.size();
    for(int u=0;u<na;u++){
        for(int v=0;v<nb;v++){
            if(!legal(a[u],b[v]))ab[u-v+offset]=true;
        }
    }
    for(int u=0;u<na;u++){
        for(int v=0;v<nc;v++){
            if(!legal(a[u],c[v]))ac[u-v+offset]=true;
        }
    }
    for(int u=0;u<nb;u++){
        for(int v=0;v<nc;v++){
            if(!legal(b[u],c[v]))bc[u-v+offset]=true;
        }
    }
    int ans=10000;
    for(int u=-nb-nc;u<=na+max(nb,nc);u++){
        for(int v=-nc-nb;v<=na+max(nb,nc);v++){
            if(!ab[u+offset]&&!ac[v+offset]&&!bc[v-u+offset]){
                int l=min(0,min(u,v));
                int r=max(na,max(u+nb,v+nc));
                ans=min(r-l,ans);
            }
        }
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,T; cin >> N >> T;
    vector<pair<int,int>> way(N);
    REP(i,N){
        int c,t; cin >> c >> t;
        way[i] = {c,t};
    }
    sort(ALL(way));

    REP(i,N){
        if(way[i].second <= T){
            cout << way[i].first << endl;;
            return 0;
        }
    }
    cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vs vector<string>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define itr ::iterator
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fne(i,a,b) for(ll i=a;i>=b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define all(v) v.begin(),v.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007
#define pi 3.14159265358979323846


int main()
{  
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
   IOS;
   
   int T=1;
   //cin>>T;
   f(t,0,T)
    { 
      ll n=0,i=0,j=0,k=0,flag=0;
      cin>>n;

      vi a(n),dp(n);
      
      f(i,0,n)
       cin>>a[i];

      dp[0]=0,dp[1]=abs(a[1]-a[0]);

      f(i,2,n)
       {
        dp[i] = min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
       }
  
      cout<<dp[n-1]<<endl;
    }
  return 0;
}


Measured memory_bytes: 4724
n = int(input())
array = [int(x) for x in input().split()]
tmp_dict = {}
tmp_dict2 = {}
tmp_array = array[::2]
tmp_array2 = array[1::2]
for i in tmp_array:
    if i in tmp_dict.keys():
        tmp_dict[i] += 1
    else:
        tmp_dict[i] = 1
for i in tmp_array2:
    if i in tmp_dict2.keys():
        tmp_dict2[i] += 1
    else:
        tmp_dict2[i] = 1

sorted_dict = sorted(tmp_dict.items(), key=lambda x: x[1], reverse=True)
sorted_dict2 = sorted(tmp_dict2.items(), key=lambda x: x[1], reverse=True)
tmp = sorted_dict[0][0]
tmp2 = sorted_dict2[0][0]

aaa = array[0]
if array.count(aaa) == len(array):
    print(len(array)//2)
    exit()

if tmp == tmp2:
    if len(sorted_dict) == 1:
        tmp2 = sorted_dict2[1][0]
    elif len(sorted_dict2) == 1:
        tmp = sorted_dict[1][0]
    else:
        if sorted_dict2[1][1] > sorted_dict[1][1]:
            tmp2 = sorted_dict2[1][0]
        elif sorted_dict2[1][1] <= sorted_dict[1][1]:
            tmp = sorted_dict[1][0]
res = 0
for i in tmp_array:
    if i != tmp:
       res += 1

for i in tmp_array2:
    if i != tmp2:
       res += 1
print(res)


Measured memory_bytes: 21568
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    string s;
    cin >> s;
    int n = s.size();
    int ans1=-1, ans2=-1;
    REP(i, n-1) {
        if(s[i] == s[i+1]) {
            ans1 = i+1;
            ans2 = i+2;
            break;
        }
    }
    if(ans1 == -1) {
        REP(i, n-2) {
            if(s[i] == s[i+2]) {
                ans1 = i+1;
                ans2 = i+3;
                break;
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}



Measured memory_bytes: 512
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let vec: Vec<i32> = read_vec();
    let res = if (vec[0] + vec[1] >= vec[2]) && vec[0] <= vec[2] {"YES"} else {"NO"};
    println!("{}", res);
}


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

string rotation(int k, string s){
	int n = s.size();
	string r;
	for(int i=0; i<n; i++) r += s[(i+k)%n];
	return r;
}

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

	bool can = false;

	for(int i=0; i<s.size(); i++){
		string u = rotation(i, s);
		if(u == t) can = true;
	}

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

Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    h = list(map(int, input().split()))
    k = h[0] - 1
    for i in h[1:]:
        if i < k: # 減少
            print("No")
            exit()
        if i == k:
            pass
        else:
            k = i - 1
    print("Yes")

if __name__=="__main__":
    main()


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

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

    long long p=1000;
    long long s=0;
    for(int i=0; i<n-1; i++){
        if(a[i]<a[i+1]){
            long long k=p/a[i];
            s += k;
            p -= a[i]*k;
        } else {
            p += s*a[i];
            s = 0;
        }
        }
    cout << p+s*a[n-1] << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v, X, Y;
  int x, y;
  rep(i, N) {
    v.push_back(i);
    cin >> x >> y;
    X.push_back(x);
    Y.push_back(y);
  }
  int count = 0;
  long double sum = 0;
  do {
    count++;
    for (size_t i = 1; i < v.size(); i++) {
      sum += sqrt(pow(X[v[i - 1]] - X[v[i]], 2) + pow(Y[v[i - 1]] - Y[v[i]], 2));
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(10) << sum / count << endl;
  return 0;
}


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

#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 3e3 + 10;

int a[maxn];

bool check(string s)
{
  int cnt = 0;
  for(const auto &c : s)
  {
    cnt += c == '(' ? 1 : -1;
    if(cnt < 0)
      return false;
  }
  return cnt == 0;
}

int main()
{
  int n;
  ios::sync_with_stdio(false);
  cin >> n;
  vector<pair<int, string>> pos, neg;
  int sum = 0;
  for(int i = 0; i < n ; i++)
  {
    string s;
    cin >> s;
    int mi = 1e9;
    int cnt = 0;
    for(const auto &c : s)
    {
      cnt += c == '(' ? 1 : -1;
      mi = min(mi, cnt);
    }
    if(cnt >= 0)
    {
      pos.push_back({mi, s});
    }
    else
    {
      neg.push_back({mi - cnt, s});
    }
    sum += cnt;
  }

  sort(pos.rbegin(), pos.rend());
  sort(neg.begin(), neg.end());
  
  string seq = "";
  for(const auto &c : pos)
  {
    seq += c.second;
  }
  
  for(const auto &c : neg)
  {
    seq += c.second;
  }

  // cout << seq << endl;
  if(check(seq))
    cout << "Yes\n";
  else
    cout << "No\n";
  

  return 0;
}

Measured memory_bytes: 45048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, a, b;
    cin>>n>>a>>b;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin>>p[i];
    }

    int p1=0, p2=0, p3=0;
    for (int i = 0; i < n; i++) {
        if(p[i]<=a)p1++;
        else if(p[i]>=a+1&&p[i]<=b)p2++;
        else if(p[i]>=b+1)p3++;
    }
    cout<<min({p1, p2, p3})<<endl;

    return 0;
}

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





int main(){
  long  x, y, s, t, u ,z;

  while(1){
    s = 0;
    cin>>x>>y;
    if(x == 0 && y == 0) break;

    if(x <= y) swap(x, y);
    
    while(y != 0){
      x = x%y;
      t =max(x, y);
      u =min(x, y);
      x = t; y =u;
      s++;
    }

    cout<<x<<" "<<s<<endl;
    
  }

  
  return 0;
}



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

int main (void){
	
	int s[100000]={0};
	int t[100000]={0};
	int a,b,i,j,n1,n2,count=0;
	int left=0,right,mid,m,l,min=10000,minb,box;

	scanf("%d",&n1);
	
	for(i=0;i<n1;i++){
		scanf("%d",&s[i]);
	}
	
	
	
		
	right=n1-1;
	m=right;
	scanf("%d",&n2);
	for(j=0;j<n2;j++){
		//printf("-------------for ?????\????????? j = %d--------------\n",j);
		l=count;
		left=0;
		right=m;
		//printf(" for s[0]=%d\n",s[0]);
		scanf("%d",&t[j]);
		//printf(" for s[0]=%d\n",s[0]);
		//printf("left=%d,right=%d,l=%d\n",left,right,l);
		
		while(left<=right){
			//printf("-------------while ?????\????????? j = %d--------------\n",j);
			mid = ((left+right)/2);
			//printf("left=%d right=%d mid=%d\n",left,right,mid);
			//printf("t[%d]=%d s[%d]=%d\n",j,t[j],mid,s[mid]);
			if(s[mid]==t[j]){
				//printf("-------------s[mid]==t[%d] ?????\????????? --------------\n",j);
				count++;
				left=mid;
				right=mid;
				//printf("s[0]=%d s[1]=%d s[2]=%d s[3]=%d s{4}=%d\n",s[0],s[1],s[2],s[3],s[4]);
				//printf("count=%d\n",count);
			}else if(s[mid]<t[j]){
				//printf("-------------s[mid]<t[%d] ?????\????????? --------------\n",j);
				left=mid+1;
				//printf("s[0]=%d s[1]=%d s[2]=%d s[3]=%d s{4}=%d\n",s[0],s[1],s[2],s[3],s[4]);
				//printf("left=%d\n",left);
			}else{
				//printf("-------------s[mid]>t[%d] ?????\????????? --------------\n",j);
				right = mid-1;
				//printf("s[0]=%d s[1]=%d s[2]=%d s[3]=%d s{4}=%d\n",s[0],s[1],s[2],s[3],s[4]);
				//printf("right=%d\n",right);
			}
			//printf("last while s[0]=%d\n",s[0]);
		if(l<count)break;
		}
	}
	//printf("-------\n");
	printf("%d\n",count);
	//printf("-------\n");
return 0;
}

Measured memory_bytes: 1392
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

typedef long long ll;

ll g[305][305];
ll minG[305][305];
int n;

bool isPossible() {
  REP(i, n) REP(j, n) {
    minG[i][j] = g[i][j];
  }
  REP(k, n) REP(i, n) REP(j, n) {
    minG[i][j] = min(minG[i][j], minG[i][k] + minG[k][j]);
  }
  REP(i, n) REP(j, n) {
    if(minG[i][j] != g[i][j]) {
      return false;
    }
  }
  return true;
}

struct K {
  int a, b;
  ll c;
};
bool operator>(const K& a, const K& b) {
  return a.c > b.c;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) REP(j, n) {
    scanf("%lld", &g[i][j]);
  }
  if(!isPossible()) {
    puts("-1");
    return 0;
  }

  ll res = 0;
  priority_queue<K, vector<K>, greater<K> > q;
  REP(i, n) REP(j, n) {
    q.push((K){i, j, g[i][j]});
  }
  while(!q.empty()) {
    K cur = q.top(); q.pop();
    bool needed = true;
    REP(k, n) {
      if(k != cur.a && k != cur.b) {
        if(g[cur.a][k] + g[k][cur.b] == cur.c) {
          needed = false;
          break;
        }
      }
    }
    if(needed) {
      // cerr << "needed: " << cur.a << " " << cur.b << " " << cur.c << endl;
      res += cur.c;
    }
  }

  printf("%lld\n", res / 2);
  return 0;
}


Measured memory_bytes: 3828
#include <cstdio>

int main(){
    char s[201];
    scanf("%s",s);
    int countls = 0;
    for(int i = 0; s[i] != '\0'; i++){
        countls++;
    }
    for(int i = countls - 1; i >= 2; i--){
        if(i % 2 != 0){
            continue;
        }else{
            for(int j = 0; j < i / 2; j++){
                if(s[j] != s[j + i / 2]){
                    break;
                }
                if(j == i / 2 - 1){
                    printf("%d\n",i);

                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 128
facts = [1]
mod = 10**9 + 7
for i in range(1, 100001):
	facts.append((i*facts[-1])%mod)
modinv = []
for i in facts:
	modinv.append(pow(i, mod - 2, mod))

def combi(a, b):
	if b > a:
		return 0
	return (((facts[a]*modinv[b])%mod)*modinv[a-b])%mod

n, k = map(int, raw_input().split())
ans = 0

l = map(int, raw_input().split())
l.sort()

for i in range(n):
	ans = (ans + (l[i]*combi(i, k - 1))%mod - (l[i]*combi(n - i - 1, k - 1))%mod)%mod 
print ans

Measured memory_bytes: 17652
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std ;

int main()
{
	int N , M = 0  ;  
	cin >> N ; // N 是花的钱 M 是个数 
	while( N > M * 1000 ){
		M ++ ;
	} 
	cout << M * 1000 - N ; 
	
	return 0 ; 
 } 

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) {
        cin >> e;
        e--;
    }

    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 0);

    sort(ans.begin(), ans.end(), [&](int s, int t) {
        return a[s] < a[t];
    });

    for (auto e: ans) cout << e+1 << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
from collections import Counter
from itertools import groupby, accumulate

n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())

remain = len(cnt)
total = 0
kkk = [0] * (n + 1)
p = 1

for c, itr in groupby(cnt):
    l = len(list(itr))
    for i in range(p, c + 1):
        kkk[remain + total // i] = i
    remain -= l
    total += c * l
    p = c + 1

for i in range(p, n + 1):
    kkk[remain + total // i] = i

kkk.reverse()
kkk = list(accumulate(kkk, func=max))
kkk.reverse()

print(*kkk[1:])


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

ll seven53(ll n)
{
    ll res = 0;
    ll base = 1;
    ll nums[4] = {0, 3, 5, 7};
    while (n > 0)
    {
        res += nums[n % 4] * base;
        n /= 4;
        base *= 10;
    }
    return res;
}

bool check(ll n)
{
    int three = 0;
    int five = 0;
    int seven = 0;
    while (n > 0)
    {
        int now = n % 10;
        if (now == 3) three++;
        else if (now == 5) five++;
        else if (now == 7) seven++;
        else return false;
        n /= 10;
    }
    return three > 0 and five > 0 and seven > 0;

}

int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; seven53(i) <= n; i++)
    {
        ll num = seven53(i);
        // cout << num << endl;
        cnt += int(check(num));
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include<algorithm>
#include <queue>
#define rep(i, a) for(int i=0; i<(int)(a); i++)
using namespace std;
int v, n, c, e,u,r,k;
const  long long int INF = (1<<21);
vector<pair<int, int>> ad[10000];
 void dijkstra() {
     priority_queue<pair<int, int>> p;
     int d[10000], co[10000];
     rep(i, n) {
         d[i] = INF;
         co[i] = 0;
     }
     d[0] = 0;
     p.push(make_pair(0, 0));
     co[0] = 1;
     while (!p.empty()) {
         pair<int, int> f = p.top();p.pop();
         int u = f.second;
         co[u] = 2;
         if (d[u] < f.first * (-1)) continue;
         rep(j, ad[u].size()) {
             int v = ad[u][j].first;
             if (co[v] != 2) {
                 if (d[v] > d[u] + ad[u][j].second) {
                     d[v] = d[u] + ad[u][j].second;
                     p.push(make_pair(d[v] * (-1), v));
                     co[v] = 1;
                 }
             }
         } 
     }
     rep(i, n) {
         cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
     }
}
int main()
{
    cin >> n;
    rep(i, n) {
        cin >> u >> k;
        rep(j, k) {
            cin >> v >> c;
            ad[u].push_back(make_pair(v, c));
        }
    }
    dijkstra();
}


Measured memory_bytes: 8036