akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    b[i]=a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(b[i]==a[n-1]){
      cout<<a[n-2]<<endl;
    }
    else{
      cout<<a[n-1]<<endl;
    }
  }
}

Measured memory_bytes: 3200
#include<iostream>

using namespace std;

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	int x = a + w;
	int y = b + w;
	if (a < b) {
		if (b - x < 1) {
			cout << 0 << endl;
		}
		else {
		cout << b - x << endl;
		}
	}
	else {
		if (a - y < 1) {
			cout << 0 << endl;
		}
		else {
          cout << a - y << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define HR 1000000007
using namespace std;
char s[1005];
int dp[1005][1005];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	dp[1][1]=1;
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		for (int j=1;j<=m;j++)
		if ((i!=1||j!=1)&&(s[j]!='#')) dp[i][j]=(dp[i-1][j]+dp[i][j-1])%HR;
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

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


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

    string S,T;
    cin >> S >> T;
    int ans = 0;
    if (S[0] == T[0]){
        ans++;
    }
    if (S[1] == T[1]){
        ans++;
    }
    if (S[2] == T[2]){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
int n;
int x[102],cnt=0;
//最大公約数
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint modpow(mint a,ll n){
    mint res = 1;
    while(n > 0){
        if(n & 1) res = res * a ;
        a = a * a;
        n >>= 1;//nを２のベキに分解している
    }
    return res;
}
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int a[100010];


int main(){
    int m;
    cin>>n>>m;
    a[0]=-1;a[m+1] = n+1;
    for (int i = 1; i <m+1; i++)
    {
        cin>>a[i];
        if(i>=2&&a[i]<=a[i-1]+1) {cout<<0<<endl;return 0;}
    }
    mint dp[n+5];
    for (int i = 0; i < n+2; i++)
    {
        if(i==1||i==0)dp[i]=1;
        else dp[i] = dp[i-1]+dp[i-2];
    }
    
    mint ans =1;

    rep(i,m+1){
        ans *= dp[a[i+1]-a[i]-2];
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1280
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  set<ll>S;
  vl vec;
  map<ll,ll>M;
  rep(i,n){
    M[a[i]]++;
    if(!S.count(a[i])){
      vec.push_back(a[i]);
      S.insert(a[i]);
    }
  }
  if(vec.size()==1&&vec[0]==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(S.size()==2&&n%3==0&&M[0]==n/3){
    cout<<"Yes"<<endl;
    return 0;
  }
  if((vec[0]^vec[1])==vec[2]&&M[vec[0]]==M[vec[1]]&&M[vec[1]]==M[vec[2]]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> A(in());
	for (int &a : A)
		a = in();
	for (int i = in(); i; i--) {
		auto r = equal_range(A.begin(), A.end(), in());
		outl(r.first - A.begin(), ' ', r.second - A.begin());
	}
}


Measured memory_bytes: 2632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<long, long>;
#define fi first
#define se second

#define INF 1000000000000

int main() {
    int n;
    cin >> n;
    P probs[n];
    long ans = 0;
    for (auto &p:probs) {
        cin >> p.fi >> p.se;
        ans = max(ans, p.se - p.fi + 1);
    }
    sort(probs, probs+n);
    long rmin = INF;
    P from_back[n+1];
    fill(from_back, from_back+n+1, P{0, INF});
    for (int i=n-1; i>=0; i--) {
        from_back[i].fi = max(from_back[i+1].fi, probs[i].fi);
        from_back[i].se = min(from_back[i+1].se, probs[i].se);
    }
    for (int i=0; i<n-1; i++) {
        P p = probs[i], fb = from_back[i+1];
        if (i > 0) {
            long maxl = fb.fi,
                 minr = min(rmin, fb.se);
            ans = max(ans, p.se - p.fi + 1 + max(0l, minr - maxl + 1));
        }
        rmin = min(rmin, p.se);
        ans = max(ans, max(0l, rmin - p.fi + 1) + max(0l, fb.se - fb.fi + 1));
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3328
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;




void main() {
    int N;
    scan(N);
    auto a = iota(N).map!(i => readln.chomp.to!int).array;

    auto dp = repeat(inf, N + 1).array.assumeSorted();
    dp[0] = -1;

    int ans;

    foreach (i ; 0 .. N) {
        auto j = dp.lowerBound(a[i]).length.to!int;
        chmin(dp[j], a[i]);
        chmax(ans, j);
    }

    writeln(ans);
}



Measured memory_bytes: 4012
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::string s; cin >> s;
	
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '1') cout << 9;
		else if(s[i] == '9') cout << 1;
		else cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		int sx = in.nextInt(), sy = in.nextInt();
		int tx = in.nextInt(), ty = in.nextInt();
		StringBuilder sb = new StringBuilder();
		String sud = "UD";
		String srl = "RL";
	
		for (int j=0; j<2; ++j) {
			char ch1 = sud.charAt(j), ch2 = srl.charAt(j);
			for (int i=sy; i<ty; ++i) {
				sb.append(ch1);
			}
			for (int i=sx; i<tx; ++i) {
				sb.append(ch2);
			}
		}
		
		for (int j=0; j<2; ++j) {
			char ch1 = sud.charAt(j), ch2 = srl.charAt(j);
			sb.append(srl.charAt(j^1));
			for (int i=sy; i<=ty; ++i) {
				sb.append(ch1);
			}
			for (int i=sx; i<=tx; ++i) {
				sb.append(ch2);
			}
			sb.append(sud.charAt(j^1));
		}

		out.println(sb.toString());
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;


	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}


	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}



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

using namespace std;

int main(){

  int N;
  string c;

  cin >> N ;
  cin >> c;
  int R = 0;
  for(int i = 0; i < N ; i++)
    if(c[i] == 'R') R++;
  int ans = 0;
  for(int i = 0; i < R ;i++)
    if(c[i] == 'W') ans++;
  cout << ans << endl;

}


Measured memory_bytes: 3732
n = int(input())
vs = [int(elem) for elem in input().split()]

vs = sorted(vs)
res = 0
for i, v in enumerate(vs):
  if i == 0:
    res = (v + vs[i+1]) / 2
  elif i < len(vs) - 1:
    res = (res + vs[i+1]) / 2
print(res)

Measured memory_bytes: 3060
using System;

namespace ALDS1_4_B
{
    public abstract class Array<T>
    {
        protected T[] array;
        public int Count { get; protected set; }
        public Array(int capacity)
        {
            array = new T[capacity];
            Count = 0;
        }
        public Array(int capacity, T initValue)
        {
            array = new T[capacity];
            for (int i = 0; i < capacity; ++i) array[i] = initValue;
            Count = capacity;
        }
    }

    public class List<T> : Array<T>
    {
        public static int AUTOSIZE = 1024;
        public static int INCSIZE = 1024;

        protected int capacity;
        protected readonly int incSize;
        public List(T[] array) : base(array.Length)
        {
            capacity = array.Length;
            incSize = INCSIZE;
            array.CopyTo(this.array, 0);
            Count = array.Length;
        }

        public bool Contains(T element)
        {
            foreach (var e in array) if (e.Equals(element)) return true;
            return false;
        }
    }

    public class SortedList<T> : List<T> where T : IComparable<T>
    {
        public SortedList(T[] array) : base(array) { }
        public int IndexOf(T element)
        {
            int left = 0, right = Count - 1;
            while (left + 1 < right)
            {
                var mid = (left + right) / 2;
                if (element.CompareTo(array[mid]) < 0) right = mid;
                else left = mid;
            }
            if (array[left].Equals(element)) return left;
            else if (array[right].Equals(element)) return right;
            else throw new Exception();
        }
        public new bool Contains(T element)
        {
            try
            {
                IndexOf(element);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var S = new SortedList<int>(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
            Console.ReadLine();
            var T = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

            int cnt = 0;
            foreach (var a in T)
            {
                if (S.Contains(a)) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 22020
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n),y(n);
    rep(i,n) {
        cin >> a[i];
        rep(j,a[i]) {
            int a,b;
            cin >> a >> b;
            x[i].push_back(a);
            y[i].push_back(b);
        }
    }
    int ans = 0;
    rep(i,1<<n) { //正直者のbitを立てる
        bool check = true;
        rep(j,n) {
            if (i & 1<<j) { //j番目の人が正直者と仮定されている場合
                rep(k,a[j]) { //j番目の人の証言を精査
                    if (!(((i >> (x[j][k]-1)) & 1) ^ y[j][k])) continue;
                    else {
                        check = false;
                        break;
                    }
                }
            }
            if (!check) break;
        }
        if (check) { //正直者の証言が全て正しければ
            int s = __builtin_popcount(i);
            chmax(ans,s);
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3560
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int inf=2e9;
const int MAXN=2e5+10;
int n,a[MAXN],b[MAXN],tot;
struct Segtree
{
	struct node
	{
		int tag,mi;
	}Tree[MAXN<<2];
#define root Tree[o]
#define lson Tree[o<<1]
#define rson Tree[o<<1|1]
	void pushup(int o)
	{
		root.mi=min(lson.mi,rson.mi);
	}
	void modify(int o,int c)
	{
		root.tag+=c;
		root.mi+=c;
	}
	void pushdown(int o)
	{
		if(root.tag)
		{
			modify(o<<1,root.tag);
			modify(o<<1|1,root.tag);
			root.tag=0;
		}
	}
	void BuildTree(int o,int l,int r)
	{
		root.tag=0;
		if(l==r)
			return (void)(root.mi=b[l]);
		int mid=(l+r)>>1;
		BuildTree(o<<1,l,mid);
		BuildTree(o<<1|1,mid+1,r);
		pushup(o);
	}
	void upd(int o,int l,int r,int L,int R,int c)
	{
		if(L<=l && r<=R)
			return modify(o,c);
		int mid=(l+r)>>1;
		pushdown(o);
		if(L<=mid)
			upd(o<<1,l,mid,L,R,c);
		if(R>mid)
			upd(o<<1|1,mid+1,r,L,R,c);
		pushup(o);
	}
	int query(int o,int l,int r,int L,int R)
	{
		if(L<=l && r<=R)
			return root.mi;
		int res=inf;
		int mid=(l+r)>>1;	
		pushdown(o);
		if(L<=mid)
			res=min(res,query(o<<1,l,mid,L,R));
		if(R>mid)
			res=min(res,query(o<<1|1,mid+1,r,L,R));
		return res;
	}
}T;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
		a[i]=b[i]=read();
	sort(b+1,b+1+n);
	tot=unique(b+1,b+1+n)-b-1;
	T.BuildTree(1,1,tot);
	ll ans=0;
	for(int i=1;i<=n;++i)
	{
		int x=lower_bound(b+1,b+1+tot,a[i])-b;
		ans+=T.query(1,1,tot,x,tot)-a[i];
		if(x>1)
			T.upd(1,1,tot,1,x-1,1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7936
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var n = F;
		WriteLine(Strs.Any(s => s == "Y") ? "Four" : "Three");
	}
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    pair<int, int> job[N]; //終了時刻, 所要時間のペア
    rep(i, N){
        int fin, need; cin >> need >> fin;
        job[i] = make_pair(fin, need);
    }
    sort(job, job+N);

    int now = 0;
    rep(i, N){
        now += job[i].second;
        if(now > job[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    ll m = n / k;
    ll ans = m * m * m;
    if(k % 2 == 0 && n >= k / 2){
        ll m2 = (n + k / 2) / k;
        ans += m2 * m2 * m2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n, p;
	while(cin >> n >> p, n || p ){
		int person[1000] = {0};
		int index = 0, owan = p, ans;
		while( true ){
			if( owan > 0 ){
				owan--;
				person[index]++;
			}else{
				owan += person[index];
				person[index] = 0;
			}
			if( owan == 0 && person[index] == p ){
				ans = index;
				break;
			}
			index++;
			if( index >= n ) index = 0;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 868
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.rbegin(), A.rend());
    vector<pair<long long, long long>> S;

    for(int i = 1; i < N-1; i++) {
        if(A[i] >= 0) {
            S.push_back(make_pair(A[N-1], A[i]));
            A[N-1] -= A[i];
        } else {
            S.push_back(make_pair(A[0], A[i]));
            A[0] -= A[i];
        }
    }
    S.push_back(make_pair(A[0], A[N-1]));
    A[0] -= A[N-1];
    cout << A[0] << endl;
    for(pair<int, int> p: S) {
        cout << p.first << " " << p.second << endl;
    }
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  
  double all=0;
  vector<int>a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    all+=a[i];
  }
  
  int count=0;
  for(int i=0; i<n; i++){
    if(a[i]>=all/(4*m)){
      count++;
    }
  }
  
  if(count>=m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;

  
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



#define int int64_t
signed main()
{
	int n; cin >> n;
	vector<double> v(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> v[i];
	

	sort(v.begin(), v.end());

	for(int i = 1; i < n; ++i){
		v[i] = (v[i]+v[i-1])/2.0;
	}

	cout << v[n-1];


}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
deque<int>st;ll n,k;int pos;
int main(){
	scanf("%lld",&n);++n;
	while((1ll<<pos)<=n)++pos;
	fd(i,pos-2,0){
		st.push_back(++k);
		if(n>>i&1)st.push_front(++k);
	}
	printf("%d\n",k<<1);
	fp(i,0,k-1)printf("%d ",st[i]);
	fp(i,1,k)printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, A[201010], vis[201010];
vector<int> z;
int cnt[201010];
int zi[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N, greater<int>());

    rep(i, 0, N) z.push_back(A[i]);
    sort(all(z));
    z.erase(unique(all(z)), z.end());
    rep(i, 0, N) {
        zi[i] = lower_bound(all(z), A[i]) - z.begin();
        cnt[zi[i]]++;
    }
    z.push_back(inf);

    int ans = 0;
    rep(i, 0, N) {
        rrep(b, 30, 0) {
            int goal = 1 << b;
            if (goal - A[i] <= 0) continue;
            if (A[i] < goal - A[i]) continue;
            
            if (goal - A[i] == A[i]) {
                if (2 <= cnt[zi[i]]) {
                    cnt[zi[i]] -= 2;
                    ans++;
                }
            } else {
                int j = lower_bound(all(z), goal - A[i]) - z.begin();
                if (z[j] == goal - A[i] and 0 < cnt[zi[i]] and 0 < cnt[j]) {
                    cnt[zi[i]]--;
                    cnt[j]--;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main()
{
    int n, m, k, ans = 0, maxi = -1;
    bool out = false;
    cin >> n >> m >> k;
    int a[n + 1], b[m + 1];
    a[0] = 0;
    b[0] = 0;
    long long total = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(total + a[i] <= k && !out)
        {
            total += a[i];
            maxi = i;
        }
        else
        {
            out = true;
        }
    }
    for(int i = 1; i <= m; i++)
    {
        cin >> b[i];
    }
    for(int i = maxi, j = 0; i >= 0; i--)
    {
        while(j < m && total + b[j + 1] <= k)
        {
            total += b[++j];
        }
        ans = max(ans, i + j);
        total -= a[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

vector<string> board(80);
string memo[80][80];
int W, H;

inline bool isDigit(int x, int y)
{
    if ('0' <= board[y][x] && board[y][x] <= '9')
        return true;
    else
        return false;
}

string Rec(int x, int y)
{
    if (memo[y][x].size() != 0)
        return memo[y][x];

    string s, tmp;
    for (int d = 0; d < 2; ++d) {
        int nx = x + dx[d];
        int ny = y + dy[d];

        if (nx < 0 || nx >= W || ny < 0 || ny >= H || !isDigit(nx, ny))
            continue;

        tmp = Rec(nx, ny);
        if (tmp.size() > s.size() || (tmp.size() == s.size() && tmp > s))
            s = tmp;
    }

    return memo[y][x] = board[y][x] + s;
}

int main()
{
    while (cin >> W >> H, W || H) {
        // Input
        for (int i = 0; i < H; ++i)
            cin >> board[i];

        // Init
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                memo[i][j] = "";

        // Solve
        string tmp, ans;
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                if (isDigit(j, i)) {
                    tmp = Rec(j, i);
                    int index = 0;
                    while (tmp[index] == '0')
                        index++;
                    tmp = tmp.substr(index);

                    if (tmp.size() > ans.size() || (tmp.size() == ans.size() && tmp > ans))
                        ans = tmp;
                }

        // Output
        cout << ans << endl;
//        cout << ans.substr(index) << endl;
    }

    return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int h, w;
vector< vs32 > field(100, vs32(100, 1));

void cmd1(int x)
{
    rep (i, h)
    {
        rep (j, w)
        {
            if (j <= x) field[i][j] = 0;
        }
    }
}

void cmd2(int x)
{
    rep (i, h)
    {
        rep (j, w)
        {
            if (j > x) field[i][j] = 0;
        }
    }
}

void cmd3(int y)
{
    rep (i, h)
    {
        rep (j, w)
        {
            if (i <= y) field[i][j] = 0;
        }
    }
}

void cmd4(int y)
{
    rep (i, h)
    {
        rep (j, w)
        {
            if (i > y) field[i][j] = 0;
        }
    }
}

void (*cmd[4])(int) = {cmd1, cmd2, cmd3, cmd4};

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

    int n;
    cin >> w >> h >> n;

    int x, y, a;
    rep (i, n)
    {
        cin >> x >> y >> a;
        --x; --y; --a;
        cmd[a]((a > 1 ? y : x));
    }

    int ans = 0;
    rep (i, h) rep (j, w) ans += field[i][j];

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



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	string S;
	cin >> N >> S;
	ll cnt[26] = {};
	for (int i = 0; i < N; i++) cnt[S[i] - 'a']++;
	ll ans = 1;
	for (int i = 0; i < 26; i++) {
		(ans *= (cnt[i] + 1)) %= MOD;
	}
	(ans += MOD - 1) %= MOD;
	cout << ans << endl;
 }

Measured memory_bytes: 512
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


def factorize(n, primes):
    import collections
    if n < 2:
        return dict()
    counter = collections.Counter()
    for p in primes:
        while n % p == 0:
            counter[p] += 1
            n //= p
        if n == 1:
            break
    if n > 1:
        counter[n] += 1
    return counter


MOD = 10**9 + 7

n = ri()
ls = ril()
if n == 1:
    print(1)
    exit()

sieve = eratosthenes(10**3)
primes = [x for x, b in enumerate(sieve) if b]

lcm = collections.Counter()
for x in ls:
    counter = factorize(x, primes)
    for p, k in counter.items():
        lcm[p] = max(lcm[p], k)
lcm_val = 1
for p, k in lcm.items():
    lcm_val *= pow(p, k, MOD)
    lcm_val %= MOD

res = 0
for x in ls:
    res += lcm_val * pow(x, MOD - 2, MOD)
    res %= MOD
print(res)

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

using namespace std;

int main()
{
  int N, K; cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) cin >> h[i];

  sort(h.begin(), h.end());

  int ans = 1e9;
  for (int i = 0; i < N-K+1; i++) {
    ans = min(ans, h[i+K-1]-h[i]);
  }

  cout << ans;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;
import java.util.ArrayList;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			ArrayList<Double> a = new ArrayList<Double>();
			ArrayList<Integer> n = new ArrayList<Integer>();
			while ((buf = br.readLine())!=null) {
				StringTokenizer st = new StringTokenizer(buf,",");
				n.add(Integer.parseInt(st.nextToken()));
				a.add(BMI(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken())));
			}
			for (int i=0;i<a.size();i++) {
				if (a.get(i)>=25.0) System.out.println(n.get(i));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static double BMI(double w,double h) {
		return w/Math.pow(h,2);
	}
}

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

 
int main() {


    int h,w;
    cin>>h>>w;


    vector<vector<char>> C(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>C.at(i).at(j);
        }
    }


    //縦を2倍する
    vector<vector<char>> C2(2*h,vector<char>(w));
    for(int i=h-1;i>=0;i--){
        for(int j=0;j<w;j++){
            C2.at(i*2).at(j)=C.at(i).at(j);
        }
    }

    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            if(i%2==0)
                cout<<C2.at(i).at(j);
            else
                cout<<C2.at(i-1).at(j);
        }
            cout<<endl;
    }


 	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  ll a;
  int b, c;
  scanf("%lld %d.%d", &a, &b, &c);
  a *= (b * 100 + c);
  printf("%lld\n", a / 100);
  return 0;
}

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

int main() {
        int a, b, c, ab, cc;
        int i, j, x;
        int ai=0, dn=0, tk=0, sa=0;

        while(1) {
                cin >> a >> b >> c;
                if (a > b) {
                        x = b;
                        b = a;
                        a = x;
                }
                if (b > c) {
                        x = c;
                        c = b;
                        b = x;
                }
                if ((a + b) <= c) {
                        break;
                }
                sa++;
                ab = (a * a) + (b * b);
                cc = c * c;
                if (ab == cc) {
                        tk++;
                } else {
                        if (ab > cc) ai++;
                        if (ab < cc) dn++;
                }
        }
        cout << sa << " " << tk << " " << ai << " " << dn << endl;
        return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL N, M, S, A[50];
inline LL ceil(LL d, LL n) {return (d+n-1)/n;}
inline bool ok(LL x) {
  if(M < S-x) return false;
  LL s = 0;
  for(auto i=0; i<N; ++i) s += max(0ll, ceil(A[i]+x+1-N, N+1));
  return s <= x;
}
int main() {
  scanf("%lld", &N);
  M=N*(N-1);
  for(auto i=0; i<N; ++i) scanf("%lld", A+i), S+=A[i];
  LL l = -1, h = 1e18;
  while(l+1 < h) {
    LL m = (l+h)>>1;
    if(ok(m)) h = m;
    else      l = m;
  }
  for(auto x=max(0ll,h-N*N); x<=h; ++x) if(ok(x)) {
    printf("%lld\n",x);
    break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    ll ans = 0;
    rep(i, k) ans += p[i];
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3556
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>

typedef long long i64;

using namespace std;

int main(){
    string s;
    cin>>s;
    int sum=0;
    
    for(int i=0;i<s.size();i++) sum += (s[i] - '0');

    int a = stoi(s);
    if(a % sum == 0) cout<<"Yes\n";
    else cout<<"No\n";

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
int x,y;
int main(){FAST;
cin>>x>>y;
int ans = 0;
if(x == 1)ans+=300000;
else if(x == 2)ans+=200000;
else if(x == 3)ans+=100000;
if(y == 1)ans+=300000;
else if(y == 2)ans+=200000;
else if(y == 3)ans+=100000;
if(x*y == 1)ans+=400000;
cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    cout << 48-N << endl; 
}


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

using ll = long long;
using ld = long double;
#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define PB push_back

struct equation {
  ll m, b; // y = m * x + b
  ll y(ll x0){return m * x0 + b;}
  ld intersect(equation o){return (ld) (o.b - b) / (m - o.m);}
};

struct CHT {
  deque<equation> hull;
  void add(const equation &e) {
    while (hull.size() > 1 and hull.rbegin()[1].intersect(e) < hull.rbegin()[1].intersect(hull.rbegin()[0]))
      hull.pop_back();
    hull.PB(e);
  }
  ll get(ll x0) {
    if(hull.empty()) return 0; // PS
    while (hull.size() > 1 and hull[0].y(x0) > hull[1].y(x0))
      hull.pop_front();
    return hull[0].y(x0);
  }
};

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

  int n; ll c;
  cin >> n >> c;
  vector<ll> a(n);
  trav(i, a) cin >> i;

  CHT cht;
  vector<ll> dp(n);
  cht.add({-2 * a[0], dp[0] + a[0] * a[0]});
  rep(i, 1, n) {
    dp[i] = cht.get(a[i]) + c + a[i] * a[i];
    cht.add({-2 * a[i], dp[i] + a[i] * a[i]});
  }
  cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 5632
import collections
n = int(input())
d = collections.defaultdict(int)
for i in range(n):
  d[str(input())] += 1
print(f"AC x {d['AC']}")
print(f"WA x {d['WA']}")
print(f"TLE x {d['TLE']}")
print(f"RE x {d['RE']}")

Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;


int main() {
 string s;
 cin>>s;
 int count =0;
 for(int i=0;i<s.size();i++){
     if(i+1<s.size()&&s[i+1]==s[i]){continue;}
     count++;
 }
 cout<<count-1<<endl;
 return 0;
}


Measured memory_bytes: 512
n = int(input())
s = []
for i in range(n):
    s.append(input())

import collections
u = collections.Counter(s)

m = max(u.values())
v = []
for j in list(u.items()):
    if j[1] == m:
        v.append(j[0])   

v.sort()
for i in v:
    print(i)

Measured memory_bytes: 117072
#include <iostream>

using namespace std;

int main()
{
  int n;
  int ans[200010] = {};
  
  cin >> n;
  
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    ans[a]++;
  }
  
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4420
def cal():
    N,Y = map(int,input().split())

    x,y,z = 0,0,0

    an = [-1]*3
    #print(*an)

    for i in range(N+1):
        for j in range(N-i+1):
            if i*10000 + j *5000 +1000*(N - i - j) == Y:
                an[0] = i
                an[1] = j
                an[2] = N-i-j
                print(*an)
                return
    
    print(*an)


if __name__ == "__main__":
    cal()
                


Measured memory_bytes: 64568
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ll n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  rep(i,0,n){
    cout<<s[i]<<t[i];
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
set<int> U;
map<char, set<int> > SET;
 
set<int> solve(string s, int d) {
//  cout << string(d, ' ') << s << endl;
  int nest = 0;
  set<int> res;
  for (int i=s.size()-1; i>=0; --i) {
//  REP(i, s.size()) {
    if (s[i]=='(')
      nest++;
    else if (s[i]==')')
      nest--;
    else if (nest == 0) {
      if (s[i]=='u' || s[i]=='i' || s[i]=='d' || s[i]=='s') {
        set<int> A = solve(s.substr(0, i), d+1);
        set<int> B = solve(s.substr(i+1), d+1);

        if (s[i]=='u') {
          res = A;
          res.insert(ALL(B));
        } else if (s[i]=='i') {
          FOR(it, A) {
            if (B.find(*it)!=B.end()) {
              res.insert(*it);
            }
          }
        } else if (s[i]=='d') {
          FOR(it, A) {
            if (B.find(*it)==B.end()) {
              res.insert(*it);
            }
          }
        } else if (s[i]=='s') {
          FOR(it, A) {
            if (B.find(*it)==B.end()) {
              res.insert(*it);
            }
          }
          FOR(it, B) {
            if (A.find(*it)==A.end()) {
              res.insert(*it);
            }
          }
        }
        // cout << string(d, ' ');
        // FOR(it, res)
        //   cout << *it << " ";
        // cout << endl;
        return res;
      }
    }
  }
  
  if (s[0] == '(') {
    return solve(s.substr(1, s.size()-2), d+1);
  } else if (s[0] == 'c'){
    set<int> A = solve(s.substr(1), d+1);
    FOR(it, U) {
      if (A.find(*it) == A.end())
        res.insert(*it);
    }
    // cout << string(d, ' ');
    // FOR(it, res)
    //   cout << *it << " ";
    // cout << endl;
    return res;
  }
  // cout << string(d, ' ');
  // FOR(it, SET[s[0]])
  //   cout << *it << " ";
  // cout << endl;
  return SET[s[0]];
}

int main() {
  char c;
  int m;
  while(cin >> c>> m) {
    U.clear();
    SET.clear();
    while(c!='R') {
      REP(i, m) {
        int a;
        cin >> a;
        SET[c].insert(a);
        U.insert(a);
      }
      cin >> c >> m;
    }
    string s;
    cin >> s;

    set<int> res = solve(s,0);
    int hoge = 0;
    if (res.size() == 0)cout << "NULL";
    FOR(it, res) {
      if (hoge)
        cout << " ";
      else hoge = 1;
      cout << *it;
    }
    cout << endl;
  }
}

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

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll>abc(3);
    lrep(i, 0, n){
        if(s[i] == 'a')abc[0]++;
        if(s[i] == 'b')abc[1]++;
        if(s[i] == 'c')abc[2]++;
    }
    sort(abc.begin(), abc.end());
    if(abc[2]-abc[0] <= 1)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,b,c,d,n;
	int count=0;
	while(scanf("%d",&n)!=EOF)
	{
		for(a=0;a<=9;a++)
		{
			for(b = 0;b<=9;b++)
			{
				for(c=0;c<=9;c++)
				{
					for(d=0;d<=9;d++)
					{
						if(a+b+c+d==n) count++;

					}
				}
			}
		}
		printf("%d\n",count);
		count =0;
	}
	return 0;

}

Measured memory_bytes: 596
import * as fs from 'fs';

function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

const input = fs.readFileSync("/dev/stdin", "utf8");
const pick = Picker(input);

//////////////////////////////////////////

const n = pick.int();
let c = 0;
let start = 0, end = 0, both = 0;
for (let i = 0; i < n; ++i) {
  const s = pick.str();
  c += s.split('AB').length - 1;

  if (s[0] === 'B' && s[s.length - 1] === 'A') {
    both++;
  } else if (s[0] === 'B') {
    start++;
  } else if (s[s.length - 1] === 'A') {
    end++;
  }
}
// console.log(c, both, start, end);

if (start && end) {
  c += both;
  c += start < end ? start : end;
} else if (!start && !end) {
  c += both ? both - 1 : 0;
} else {
  c += both;
}

console.log(c);

Measured memory_bytes: 23100
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll l,r; cin>>l>>r;
	ll mod = 2019LL;
	vint ans;
	if(r-l+1>=2019){cout<<0<<endl; return 0;}
	for(ll i = l; i<=r; ++i){
		ans.push_back(i%mod);
	}
	int res = inf;
	for(int i = 0; i<ans.size(); ++i){
		for(int j=i+1; j<ans.size(); ++j){
			res = min(res, (int)((ans[i]*ans[j])%mod));
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256