akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;
	cin>>a>>b;

	ll k=abs(a-b);
	if(k%2==0){
		cout<<min(a,b)+(k/2);
	}
	else{
		cout<<"IMPOSSIBLE";
	}
	return 0;
}

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

int main() {
  int N,X,Y;

  cin >> N >> X >> Y;
  X--;
  Y--;
  int a[N-1][N];
  int k[N];

  for ( int i=0 ; i < N ; ++i ) k[i] = 0;
  for ( int i=0 ; i < N - 1 ; ++i ) {
    for ( int j=i+1 ; j < N ; ++j ) {
      a[i][j] = min(j-i,abs(X-i)+1+abs(j-Y));
      k[a[i][j]]++; 
    }
  }
  for ( int i=1 ; i < N ; ++i ) {
    cout << k[i] << endl;
  }
  return 0;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<long long> num(n);

	long long ans=0;

	for(int i=0;i<n;i++) cin>>num.at(i);

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

	vector<bool> prime(1000001,true);


	for(int i=0;i<n;i++){
		int hoge=num.at(i);

		if(prime.at(hoge)){
			for(int j=hoge*2;j<=1000000;j+=hoge){
				prime.at(j)=false;
			}

			if(i<n-1 && hoge==num.at(i+1)) prime.at(hoge)=false;
			else{
				ans++;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4748
#include<iostream>
using namespace std;
 
int main()
{
  int x = 5;
  int arr[x];
  
  for(int i =0; i<5; i++)
    cin>> arr[i];
  
  if (arr[0] == 0)
    cout<<1<<endl;
  else if (arr[1] == 0)
    cout<<2<<endl;
  else if (arr[2] == 0)
    cout<<3<<endl;
  else if (arr[3] == 0)
    cout<<4<<endl;
  else if (arr[4] == 0)
    cout<<5<<endl;
  
  return 0;
}

Measured memory_bytes: 3164
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var str string
	fmt.Scan(&str)

	slice := make([]int, 26)
	for _, v := range str {
		slice[int(v)-97] = 1
	}

	for i, v := range slice {
		if v == 0 {
			fmt.Println(string(i + 97))
			return
		}
	}

	fmt.Println("None")

}


Measured memory_bytes: 1280
n = gets.to_i
v = gets.chomp.split.map(&:to_i)
odd = Hash.new(0)
even = Hash.new(0)

(n / 2).times do |i|
  even[v[2 * i]] += 1
  odd[v[2 * i + 1]] += 1
end

ep = even.to_a.sort_by! {|_, v| v }
op = odd.to_a.sort_by! {|_, v| v }

ev1 = ep[-1][1]
ov1 = op[-1][1]
ek1 = ep[-1][0]
ok1 = op[-1][0]

if ek1 != ok1
  puts n - ov1 - ev1
else
  if ev1 + ov1 == n
    puts n / 2
  elsif ev1 == n / 2
    puts n / 2 - op[-2][1]
  elsif ov1 == n / 2
    puts n / 2 - ep[-2][1]
  else
    puts [n - ev1 - op[-2][1], n - ov1 - ep[-2][1]].min
  end
end


Measured memory_bytes: 27316
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
vector<vector<int>> L(200);
vector<int> match(200);
vector<bool> Visited(200);
bool DFS(int v)
{
	Visited[v]=true;

	for(int i=0; i<(int)L[v].size(); i++){
		int u=L[v][i], w=match[u];
		if(w<0||!Visited[w]&&DFS(w)){
			match[v]=u; match[u]=v;
			return true;
		}
	}
	return false;
}
int bipartite_matching(int n)
{
	int res=0;

	for(int i=0; i<200; i++) match[i]=-1;

	for(int v=0; v<n; v++){
		if(match[v]<0){
			for(int i=0; i<200; i++) Visited[i]=false;

			if(DFS(v)) res++;
		}
	}
	return res;
}
int main(void)
{
	int n;

	cin>>n;

	vPi red(n), blue(n);

	rep(i, n){
		int a, b;
		cin>>a>>b;
		red[i]=mp(a, b);
	}
	rep(i, n){
		int a, b;
		cin>>a>>b;
		blue[i]=mp(a, b);
	}

	rep(i, n){
		rep(j, n){
			if(red[i].first<blue[j].first&&red[i].second<blue[j].second){
				L[i].push_back(j+n);
				L[j+n].push_back(i);
			}
		}
	}
	cout<<bipartite_matching(2*n)<<endl;
}

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

int n;
long long a[2055];
long long x;
long long cur[2055];

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

	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i < n; i++) cur[i] = a[i];

	long long tot = 0;

	for (int i = 0; i < n; i++) tot += a[i];

	long long res = tot;

	for (int t = 1; t < n; t++) {
		tot += x;

		for (int i = 0; i < n; i++) {
			int left = i - t;

			if (left < 0) left += n;

			if (a[left] < cur[i]) {
				tot -= cur[i];
				tot += a[left];
				cur[i] = a[left];
			}
		}

		res = min(res, tot);
	}

	printf("%lld\n", res);

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m, nb, k;
	int[] us, vs, ws;
	int s, t;
	int[] bs;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			nb=sc.nextInt();
			k=sc.nextInt();
			if(n==0){
				break;
			}
			us=new int[m];
			vs=new int[m];
			ws=new int[m];
			for(int i=0; i<m; i++){
				us[i]=sc.nextInt()-1;
				vs[i]=sc.nextInt()-1;
				ws[i]=sc.nextInt();
			}
			s=sc.nextInt()-1;
			t=sc.nextInt()-1;
			bs=new int[nb];
			for(int i=0; i<nb; i++){
				bs[i]=sc.nextInt()-1;
			}
			solve();
		}
	}

	void solve(){
		// n*2^nb
		int N=n*(1<<nb);
		@SuppressWarnings("unchecked")
		ArrayList<E>[] es=new ArrayList[N];
		for(int i=0; i<N; i++){
			es[i]=new ArrayList<E>();
		}
		int[] has=new int[n];
		fill(has, -1);
		for(int i=0; i<nb; i++){
			has[bs[i]]=i;
		}
		for(int i=0; i<m; i++){
			int u=us[i], v=vs[i];
			// uが含んでいたら
			// S->T
			// Sはuのボールを含む
			for(int S=0; S<1<<nb; S++){
				// S->T
				if(has[u]==-1||(S>>has[u]&1)==1){
					int T=S;
					if(has[v]>=0){
						T|=1<<has[v];
					}
					int uS=u*(1<<nb)+S;
					int vT=v*(1<<nb)+T;
					es[uS].add(new E(vT, ws[i]));
					// debug(u, Integer.toBinaryString(S), v,
					// Integer.toBinaryString(T));
				}
				if(has[v]==-1||(S>>has[v]&1)==1){
					int T=S;
					if(has[u]>=0){
						T|=1<<has[u];
					}
					int vS=v*(1<<nb)+S;
					int uT=u*(1<<nb)+T;
					es[vS].add(new E(uT, ws[i]));
					// debug(u, Integer.toBinaryString(S), v,
					// Integer.toBinaryString(T));
				}
			}
		}
		int sS=s*(1<<nb);
		if(has[s]>=0){
			sS|=1<<has[s];
		}
		ArrayList<Integer> d=kDijkstra(es, sS, k)[t*(1<<nb)+((1<<nb)-1)];
		println(""+(d.size()>0?d.get(d.size()-1):"NA"));
	}

	ArrayList<Integer>[] kDijkstra(ArrayList<E>[] es, int s, int k){
		int n=es.length;
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] d=new ArrayList[n];
		for(int i=0; i<n; i++)
			d[i]=new ArrayList<Integer>();
		PriorityQueue<P> que=new PriorityQueue<P>();
		que.offer(new P(s, 0));
		for(; !que.isEmpty();){
			P p=que.poll();
			if(d[p.v].size()>=k)
				continue;
			d[p.v].add(p.d);
			for(E e : es[p.v])
				que.offer(new P(e.to, p.d+e.cost));
		}
		return d;
	}

	class E{
		int to, cost;

		E(int to, int cost){
			this.to=to;
			this.cost=cost;
		}
	}

	class P implements Comparable<P>{
		int v, d;

		P(int v, int d){
			this.v=v;
			this.d=d;
		}

		public int compareTo(P p){
			return d-p.d;
		}
	}

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

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 423996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int> > s(d);
    rep(i,d)rep(j,26){
        int a; cin >> a;
        s[i].push_back(a);
    }
 
    //vector<int> ld(26,0);
    vector<vector<int> > ds(26);
    vector<int> days(d);
    rep(i,d) days[i]=i%26;

    //ll ans=0;
    rep(i,d){
        int t=days[i];
        ds[t].push_back(i);
        /*
        ld[t]=i+1;
        ans+=s[i][t];
        rep(j,26){
            ans-=c[j]*(i+1-ld[j]);
        }
        */
    }
 
    rep(i,3000){
        rep(Q,26)rep(D,d){
        int pd=days[D];
        int be,af,be2,af2;
        int r,l;
        l=-1;
        r=ds[pd].size();
        while(l+1<r){
            int c=(l+r)/2;
            if(ds[pd][c]<=D) l=c;
            else r=c;
        }
        if(r==ds[pd].size()) af=d;
        else af=ds[pd][r];
        l=-1;
        r=ds[pd].size();
        while(l+1<r){
            int c=(l+r)/2;
            if(ds[pd][c]>=D) r=c;
            else l=c;
        }
        if(l==-1) be=-1;
        else be=ds[pd][l];

        int l2=-1;
        r=ds[Q].size();
        while(l2+1<r){
            int c=(l2+r)/2;
            if(ds[Q][c]<=D) l2=c;
            else r=c;
        }
        if(r==ds[Q].size()) af2=d;
        else af2=ds[Q][r];
        l2=-1;
        r=ds[Q].size();
        while(l2+1<r){
            int c=(l2+r)/2;
            if(ds[Q][c]>=D) r=c;
            else l2=c;
        }
        if(l2==-1) be2=-1;
        else be2=ds[Q][l2];

        if(c[Q]*(D-be2)*(af2-D)+s[D][Q]-c[pd]*(D-be)*(af-D)-s[D][pd]>0){
            days[D]=Q;
            ds[pd].erase(ds[pd].begin()+l+1);
            ds[Q].insert(ds[Q].begin()+l2+1,D);
        }
    }
    }
    rep(i,d) cout << days[i]+1 << endl;
return 0;
}

Measured memory_bytes: 3672
/*
  Contest 092
  B - Chocolate
  Rakesh Kumar --> 21/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    int d = 0, x = 0;
    std::cin >> d >> x;
    int bhojan = x;
    while (n--) {
        int a = 0;
        std::cin >> a;
        bhojan += (d - 1) / a;
        ++bhojan;
    }
    std::cout << bhojan << std::endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vec a;
    a.pb(n);
    ll i = 1;
    while(true){
        i++;
        if(n%2==1){
            n = 3*n+1;
        }else{
            n = n/2;
        }
        if(binary_search(ALL(a),n)){
            break;
        }else{
            a.pb(n);
            sort(ALL(a));
        }
    }
    cout<<i<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a[100100], b[100100], res;
pair<int,int> p[100100];

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i] >> b[i];
		p[i] = {a[i]+b[i], i};
	}
	sort(p,p+n), reverse(p,p+n);
	rep(i,n) res += (i%2==0 ? a[p[i].second] : -b[p[i].second]);
	cout << res << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
    for (unsigned i = 0; i < v.size(); i++)
        in >> v[i];
    return in;
}

void solve(){


	lo n;
	cin>>n;
	lo sum =0;
	REPV(i,1,n+1){
		if(i%3!=0 && i%5!=0){
			sum+=i;
		}
	}
	cout<<sum<<endl;

}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(20);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int dp[n];
  for(int i=0;i<n;i++)
  {
   dp[i]=INT_MAX; 
  }
  dp[0]=0;
  for(int i=0;i<n;i++)
    for(int j=1;j<=2;j++)
    {
     	if(i+j<n)
        {
        	dp[i+j]=min(dp[i+j],abs(a[i+j]-a[i])+dp[i]);
        }
    }
  cout<<dp[n-1];
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <array>
using namespace std;
          
array<long int,200001> A;  
    
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i];
    
    long int a=INT_MIN;
    long int m=INT_MAX;
    for(int i=0;i<n;i++){
       a=max(a,A[i]-m);
       m=min(m,A[i]);
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vector<ll> A(N);
	vector<ll> B(N);
	
	FDS(i,N){
		cin>>A[i]>>B[i];
	}
	
	vector<pair<ll,ll>> sa;
	FDS(i,N)FDS(j,N){
		if(i==j)continue;
		sa.push_back(make_pair(A[j]-A[i],B[j]-B[i]));
	}
	int ans=N;
	FDS(i,sa.size()){
		ll x=sa[i].first,y=sa[i].second;
		int c=0;
		FDS(k,sa.size()){
			if(sa[k].first==x&&sa[k].second==y){
				c++;
			}
		}
		ans=min(ans,N-c);
	}
	cout<<ans<<endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 300

// dp[i][j][k]:1スi枚,2スj枚,3スk枚
double dp[MAXN+1][MAXN+1][MAXN+1];
int n;

double rec(int i, int j, int k){
  if(!i && !j && !k)return 0.0;
  if(dp[i][j][k]>0.0)return dp[i][j][k];

  double sum = i+j+k;
  double ret = n/sum;
  if(i>0)ret += (double)(i/sum) * rec(i-1, j, k);
  if(j>0)ret += (double)(j/sum) * rec(i+1, j-1, k);
  if(k>0)ret += (double)(k/sum) * rec(i, j+1, k-1);

  return dp[i][j][k]=ret;
}

int main(){
  cin>>n;
  double dn=(double)n;
  vector<int>a(n);
  rep(i, n)cin>>a[i];

  map<int, int>m;
  for(auto t:a)m[t]++;

  cout<<fixed<<setprecision(12)<<rec(m[1], m[2], m[3])<<endl;

  return 0;

rep(i, n)rep(j, n)rep(k, n)cout<<dp[i][j][k]<<' '<<i<<' '<<j<<' '<<k<<endl;

  return 0;
}

Measured memory_bytes: 111160
#include<bits/stdc++.h>
using namespace std;
const int N = 199;
int dp[2][N][N][N];
int n,m;
int s[N][N];char ch[N][N];
bool chk(int x1,int y1,int x2,int y2){
	int sum = s[x1-1][y1-1]+s[x2][y2]-s[x1-1][y2]-s[x2][y1-1];
	return (!sum)||sum == (x2-x1+1)*(y2-y1+1);
}

int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)s[i][j] = s[i][j-1]+(ch[i][j]=='.');
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)s[i][j] += s[i-1][j];
	for(int i=1;i<=n;i++){
		for(int j1=1;j1<=m;j1++){
			for(int j2=j1;j2<=m;j2++){
				// cout << j1 << " " << j2 << " " << i << endl;
				int l = i,r = n, ans = i-1;
				while(l<=r){
					int mid = (l+r)>>1;
					if(chk(i,j1,mid,j2))ans = mid,l = mid+1;
					else r = mid-1;
				}
				dp[0][i][j1][j2]=ans;
			}
		}
	}//	cout << "?" << endl;
	if(dp[0][1][1][m] == n){puts("0");return 0;}
	bool u=1,v=0;
	for(int t=1;t<=16;t++,swap(u,v)){
		// cout << "checking" << t << endl;
		for(int i=1;i<=n;i++)for(int j1=1;j1<=m;j1++)
		for(int j2=j1;j2<=m;j2++){
			int d = dp[v][dp[v][i][j1][j2]+1][j1][j2];
			if(dp[v][i][j1][j2]==n){
				dp[u][i][j1][j2]=n;continue;
			}
			int l = j1,r = j2-1;
			// cout << l << " " << r << endl;
			while(l<=r){
				int mid = (l+r)>>1;
				int t1 = dp[v][i][j1][mid],t2=dp[v][i][mid+1][j2];
				d = max(d,min(t1,t2));
				if(t1>=t2)l=mid+1;
				else r=mid-1;
			}
			// cout << "!" << endl;
			dp[u][i][j1][j2]=d;
		}
		if(dp[u][1][1][m]==n){
			printf("%d\n",t);return 0;
		}
	}
}

Measured memory_bytes: 61440
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n,k;
int f[310][310][310];
char s[110];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&k);
	for (int i=1;i<=n;i++)
		for (int j=0;j<=k;j++) f[i][i][j]=1;
	for (int len=2;len<=n;len++)
		for (int l=1;l+len-1<=n;l++)
		{
			int r=l+len-1;
			for (int i=0;i<=k;i++)
			{
				if (i) f[l][r][i]=f[l][r][i-1];
				f[l][r][i]=max(f[l][r][i],f[l+1][r][i]);
				f[l][r][i]=max(f[l][r][i],f[l][r-1][i]);
				if (i) f[l][r][i]=max(f[l][r][i],f[l+1][r-1][i-1]+2);
				if (s[l]==s[r]) f[l][r][i]=max(f[l][r][i],f[l+1][r-1][i]+2);
			}
		}
	printf("%d",f[1][n][k]);
}

Measured memory_bytes: 114560
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NTL = -1;

int n;
vector<int>G[MAX];
int color[MAX];

void dfs(int r,int c){
  stack<int> S;
  S.push(r);
  color[r]=c;
  while (!S.empty()) {
    int u = S.top(); S.pop();
    for (int i =0;i < G[u].size();i++){
      int v =G[u][i];
     if(color[v]==NTL){
      color[v]=c;
      S.push(v);
      }
    }
  }
}

void assigncolor() {
  int id=1;
  for(int i=0;i<n;i++) color[i]=NTL;
  for(int u =0;u<n;u++){
    if(color[u]==NTL)dfs(u,id++);
  }
}

int main() {
  int s, t, m, q;
  
  cin >> n >> m;

  for(int i = 0;i<m;i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assigncolor();

  cin >> q;

  for(int i = 0; i<q;i++) {
    cin >> s >> t;
    if(color[s]==color[t]){
      cout << "yes"  <<  endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 8968
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
#include <algorithm>

using namespace std;

#define price first
#define weight second

int main(){
	int W;
	int cnt = 1;
	while (cin >> W, W) {
		int N; cin >> N;
		vector<pair<int, int> > tres(N);
		vector<int> dp(W+1);
		for (int i = 0; i < N; i++) { scanf("%d,%d", &tres[i].price, &tres[i].weight);}
		for (int i = 0; i < W+1; i++) { dp[i] = -1; }
		dp[0] = 0;

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

		for (int i = 0; i < N; i++) {
			for (int j = W; j >= 0; j--) {
				if (dp[j] == -1) { continue; }
				if (j+tres[i].weight <= W) {
					if (dp[j+tres[i].weight] < dp[j]+tres[i].price) {
						dp[j+tres[i].weight] = dp[j]+tres[i].price;
					}
				}
			}
		}
		int PRICE = 0;
		int WEIGHT = 0;
		for (int i = W; i >= 0; i--) {
			if (PRICE <= dp[i]) {
				PRICE = max(PRICE, dp[i]);
				WEIGHT = i;
			}
		}

		cout << "Case " << cnt << ":" << endl;
		cout << PRICE << endl;
		cout << WEIGHT << endl;
		cnt++;
	}

	return 0;
}

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

using namespace std;


int main() {
    int N;
    float x[10];
    string u[10];
    float res = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        cin >> u[i];
        if (u[i] == "JPY") {
            res += x[i];
        } else {
            res += x[i] * 380000;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

bool dfs(int idx, vector< vector< tuple< int, l64 > > > & path, vector< bool > & v, vector< l64 > & dist) {
  v[idx] = true;
  for (auto c : path[idx]) {
    int cidx = get<0>(c);
    l64 d = get<1>(c);
    if (v[cidx]) {
      if (dist[cidx] != dist[idx]+d) return false;
    } else {
      dist[cidx] = dist[idx]+d;
      bool flg = dfs(cidx, path, v, dist);
      if (!flg) return false;
    }
  }
  return true;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector< vector< tuple< int, l64 > > > path(n);
  for (int i=0; i<m; ++i) {
    int l, r;
    l64 d;
    cin >> l >> r >> d;
    l--; r--;
    path[l].push_back(make_tuple(r, d));
    path[r].push_back(make_tuple(l, -d));
  }
  vector< bool > v(n, false);
  vector< l64 > dist(n, 0);
  for (int i=0; i<n; ++i) {
    if (v[i]) continue;
    bool flg = dfs(i, path, v, dist);
    if (!flg) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 18432
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
	int n;
	cin>>n;
	int w[n-1];
	vector<vector<pair<int,int> > > tree(n);
	rep(i,n){
		int u,v,w;
		pair<int,int> p;
		cin>>u>>v>>w;
		p.first=v-1;
		p.second=w;
		tree[u-1].push_back(p);
		p.first=u-1;
		tree[v-1].push_back(p);
	}

	int val[n];
	rep(i,n)
		val[i]=-1;
	

	queue<int> que;
	val[0]=0;
	que.push(0);

	while(!que.empty()){
		int id=que.front();
		que.pop();
		rep(i,tree[id].size()){
			if(val[tree[id][i].first] == -1){
				que.push(tree[id][i].first);
				if(tree[id][i].second%2==0){
					if(val[id]==0)val[tree[id][i].first]=0;
					else val[tree[id][i].first]=1;
				}
				else{
					if(val[id]==1)val[tree[id][i].first]=0;
					else val[tree[id][i].first]=1;
				}
			}
		}
	}

	rep(i,n)cout<<val[i]<<endl;
	return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <algorithm>
 
int main(){
    using namespace std;
 
    int a, b, c;
    cin >> a >> b >> c;
     
    vector<int> vec;
    vec.push_back( a );
    vec.push_back( b );
    vec.push_back( c );
 
    sort( vec.begin(), vec.end() );
 
    for( unsigned int i = 0; i < vec.size(); ++i ){
        cout << vec[i];
        if( i != vec.size() - 1 ){
            cout << ' ';
        }else{
            cout << endl;
        }
    }
}

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

using namespace std;

bool chk1[2019];
bool chk2[2019];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l, r; cin >> l >> r;
    int ans = 2020;
    for (int i = l; i <= r; i++) {
    	if (chk1[i % 2019]) break;
    	chk1[i % 2019] = true;
    	for (int j = 0; j < 2019; j++) chk2[j] = false;
    	for (int j = i + 1; j <= r; j++) {;
    		if (chk2[j % 2019]) break;
    		chk2[j % 2019] = true;
    		ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
    	}
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010;
int x,y,a,b,c,t,tot;
ll p[MAXN*3],q[MAXN],r[MAXN],ans;
int main () {
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for (int i=1;i<=a;i++) {
		scanf("%d",&q[i]);
	}
	sort(q+1,q+a+1);
	for (int i=a;i>=a-x+1;i--) {p[++tot]=q[i];}
	for (int i=1;i<=b;i++) {
		scanf("%d",&r[i]);
	}
	sort(r+1,r+b+1);
	for (int i=b;i>=b-y+1;i--) {p[++tot]=r[i];} 
	for (int i=1;i<=c;i++) {
		scanf("%d",&t);
		p[++tot]=t;
	}
	sort(p+1,p+tot+1);
	for (int i=tot;i>=tot-x-y+1;i--) {
		ans+=p[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7436
#include <stdio.h>

int main (void) {
    char str[1200];
    int al[26] = {0};
    
    for (;fgets (str, 1200-1, stdin)!=NULL;) {
        for (int i=0; str[i]!='\0'; i++) {
            if (str[i]>='A' && str[i]<='Z') {
                al[str[i]-'A']++; 
            } else if (str[i]>='a' && str[i]<='z') {
                al[str[i]-'a']++;
            } 
        }
    }

    for (int i=0; i<26; i++) {
        printf ("%c : %d\n", i+'a', al[i]);
    }

    return 0;
}


Measured memory_bytes: 2044
while True:
	h,w=map(int, input().split())
	flag=0
	if h==0 and w==0:
		break
	for i in range(h):
		flag=i%2
		for j in range(w):	
			if j%2==0 and flag==0:
				print("#",end="")
			elif j%2==1 and flag==0:
				print(".",end="")
			elif j%2==0 and flag==1:
				print(".",end="")
			else:
				print("#",end="")
		print()					
	print()


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

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

    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> x_sort(n);
    rep(i, n) {
        cin >> x[i];
        x_sort[i] = x[i];
    }
    sort(x_sort.begin(), x_sort.end());

    int c_r = x_sort[(int)x_sort.size()/2];
    int c_l = x_sort[(int)x_sort.size()/2 - 1];

    rep(i, n) {
        if(c_r == c_l) cout << c_l << endl;
        else {
            if(x[i] >= c_r) cout << c_l << endl;
            if(x[i] <= c_l) cout << c_r << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

struct Edge { int to, id;};

vector<vector<Edge>> G;
vi ans;
int n_col;

void dfs(int v, int pc, int p=-1) {
    int color = 1;
    for (Edge e : G[v]) {
        if (e.to == p) continue;
        if (color == pc) color++;
        ans[e.id] = color;
        dfs(e.to, color, v);
        chmax(n_col, color);
        color++;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    G.resize(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].pb(Edge{b, i});
        G[b].pb(Edge{a, i});
    }
    ans.resize(n-1);
    dfs(0, 0);
    cout << n_col << endl;
    rep(i, n-1) cout << ans[i] << endl;
}

Measured memory_bytes: 8320
local DBG = false
if not DBG then
    assert = function()end
end
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

local function dbgpr_tp(tbl)
    dbgpr_t(tbl, true)
end

local function str2tbl(s)
    -- limit of #s is approximately 999959
    --local t = {string.byte(s, 1, #s)}
    local t = {}
    local a = string.byte('a')
    local char = string.char
    local sub = string.sub
    local byte = string.byte
    for i=1, #s do
        t[i] = byte(sub(s, i, i), 1, 1) - a + 1
    end
    return t
end

-- E
local S = str2tbl(io.read("*l"))
local T = str2tbl(io.read("*l"))
--dbgpr_t(S)
--dbgpr_t(T)
local function search_s(n, c)
    for i=n,#S do
        if S[i] == c then
            --return i
            return i - n + 1
        end
    end
    return false
end
local lookup = {}
lookup[0] = {}
for c=1,26 do
    lookup[0][c] = search_s(1, c)
end
for i=1,#S do
    lookup[i] = {}
    for c=1,26 do
        if c == S[i] then
            lookup[i][c] = search_s(i+1, c)
        else
            local prev = lookup[i-1][c]
            lookup[i][c] = prev and prev - 1 or false
        end
    end
end

if DBG then
    for i=0,#S do
        local tbl = lookup[i]
        dbgpr(tbl)
        dbgpr(i)
        io.write("[dbg]")
        for j,v in ipairs(tbl) do
            io.write(string.char(j+96))
            io.write(":")
            io.write(v and v or '*')
            io.write(" ")
        end
        print("")
    end
end
local cur = 0
local ans = 0
local i = 1
while i <= #T do
    local c = T[i]
    dbgpr("!", "i=", i, ans, "c=", c, "cur=", cur, "#lookup", #lookup)
    local step = lookup[cur][c]
    dbgpr(i, ans, c, cur, step)
    if step then
        dbgpr(cur, step)
        ans = ans + step
        cur = cur + step
        assert(cur <= #S)
        i = i + 1
    elseif cur ~= 0 then
        ans = ans + (#S - cur)
        cur = 0
    else
        -- cur == 0
        print("-1")
        return
    end
end
print(ans)

Measured memory_bytes: 35756
N,A,B,C=map(int,input().split())
L=[0]*N
for i in range(N):
  L[i]=int(input())

# ある竹を,Aに使う、Bに使う、Cに使う、どれにも使わない　の4パターンで全探索
# A,B,C	それぞれに対して2つ目以降は10Pかかる

stack=[]
# Aの長さ、Bの長さ、Cの長さ、処理した竹の本数、消費MP
stack.append([0,0,0,0,0])
ans=1000*10
while stack:
  a,b,c,num,mp=stack.pop()
  if num==N:
    if a==0 or b==0 or c==0:
      continue
    mp+=abs(A-a)+abs(B-b)+abs(C-c)
    if mp<ans:
      ans=mp
    continue
  stack.append([a+L[num],b,c,num+1,mp+(a!=0)*10])
  stack.append([a,b+L[num],c,num+1,mp+(b!=0)*10])
  stack.append([a,b,c+L[num],num+1,mp+(c!=0)*10])
  stack.append([a,b,c,num+1,mp])
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>

#define MAXN 300005
#define INF 2000000090

using namespace std;

int n;
long long a[MAXN], sum1[MAXN], sum2[MAXN];


int main()
{
    //freopen("d.txt", "r", stdin);
    while (scanf("%d", &n) == 1) {
        sum1[0] = sum2[0] = 0;
        for (int i = 1; i <= n; i++) {
            scanf("%I64d", a + i);
            sum1[i] = sum1[i - 1] + a[i];
            sum2[i] = sum2[i - 1] ^ a[i];
        }

        long long ans = 0;
        for (int i = 1; i <= n; i++) {
            int l = i;
            int r = n;
            while (l < r) {
                int mid = (l + r) / 2;
                if ((sum1[mid + 1] - sum1[i - 1]) == (sum2[mid + 1] ^ sum2[i - 1]))
                    l = mid + 1;
                else
                    r = mid;
            }
            ans += r - i + 1;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mp  make_pair
#define ss  second
#define ff  first
#define all(x) x.begin(),x.end()
map<string ,int>m;
void solve()
{
    string a;cin>>a;
    m[a]++;
}
int main()
{
    int t;cin>>t;
    while(t--)
    {
        solve();
    }
    string a[4]={"AC","WA","TLE","RE"};
    for(int i=0;i<4;i++)
    {
        cout<<a[i]<<" x "<<m[a[i]]<<endl;
    }
}





Measured memory_bytes: 3632
#include <iostream>
#define M 100

using namespace std;

int main() {
	int n, m, l;
	long long int A[M][M], B[M][M], C[M][M] = {};
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> B[i][j];
		}
	}
	for ( int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			cout << C[i][j];
			if (j == l - 1) {
				cout << endl;
			}
			else cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 3340
#include <stdio.h>

int main(void) {

  int h,w;
  scanf("%d %d", &h, &w);
  char a[h][w+1];
  for (int i = 0; i < h; i++) {
    scanf("%s", a[i]);
  }
  int alp[26];
  for (int i = 0; i < 26; i++) {
    alp[i] = 0;
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      alp[a[i][j]-'a']++;
    }
  }
  int need_4 = (h/2)*(w/2);
  int need_2 = 0;
  if (h%2 == 1) {
    need_2 += w/2;
  }
  if (w%2 == 1) {
    need_2 += h/2;
  }
  int stock_4 = 0;
  int stock_2 = 0;
  for (int i = 0; i < 26; i++) {
    stock_4 += alp[i]/4;
    if (alp[i]%4 == 2) {
      stock_2++;
    }
  }
  if (stock_4 >= need_4) {
    stock_2 += (stock_4-need_4)*2;
    if (stock_2 >= need_2) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  } else {
    printf("No\n");
  }

  return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

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

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while(true)
    {
        int n; cin >> n;
        if(n == 0) break;
        vd s(n); REP(i, n) cin >> s[i];
        double sum = 0, sum2 = 0;
        REP(i, n)
        {
            sum += s[i];
            sum2 += s[i]*s[i];
        }
        double a2 = sum2 / n - (sum / n)*(sum / n);
        cout << sqrt(a2) << endl;
    }
}


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

int main(){
  lint a,b,k;
  cin>>a>>b>>k;
  a-=k;
  if(a<0){
    b-=abs(a);
    a=0;
  }
  if(b<0){
    b=0;
  }
  cout<<a<<" "<<b<<endl;
}

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

#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

const ll M=1e9+7,N=1e5;
ll A[N];

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

	int a,b;
	cin>>a>>b;
	cout<<max(a-2*b,0)<<"\n";

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
L = {"R": 0, "G": 0, "B": 0}
R = {"R": s.count("R"), "G": s.count("G"), "B": s.count("B")}
ans = 0
L[s[0]]+=1
R[s[0]]-=1
for i in range(1, n - 1):
	t = s[i]
	if t == "R":
		ans += L["G"] * R["B"] + L["B"] * R["G"]
	elif t == "G":
		ans += L["R"] * R["B"] + L["B"] * R["R"]
	else:
		ans += L["R"] * R["G"] + L["G"] * R["R"]
	for j in range(min(i,n-1-i)):
		ans -= t!=s[i-j-1]!=s[i+j+1]!=t
	L[t]+=1
	R[t]-=1
print(ans)


Measured memory_bytes: 68520
#include <iostream>
#include <cmath>

using namespace::std;

int main() {
  while(true) {
    int counter = 0;
    int counter2 = 0;
    int n = 0;
    cin >> n;
    if(n == 0) break;
    int prime[n+1];
    int prime2[2*n+1]; //1????´???°

    for(int i = 1; i <= n; ++i) {
      prime[i] = 1;
    }
    prime[1] = 0;
    for(int j = 2; j <= sqrt(n); ++j) {
      if (prime[j] == 1) {
        for(int k = 2; j*k <= n; ++k) {
          prime[j*k] = 0;
        }
      }
    }
    for(int i = 1; i <= n; ++i) {
      if(prime[i] == 1) {
        counter++;
      }
    }



    for(int i = 1; i <= 2*n; ++i) {
      prime2[i] = 1;
    }
    prime2[1] = 0;
    for(int j = 2; j <= sqrt(2*n); ++j) {
      if (prime2[j] == 1) {
        for(int k = 2; j*k <= 2*n; ++k) {
          prime2[j*k] = 0;
        }
      }
    }
    
     
    for(int i = 1; i <= 2*n; ++i) {
      if(prime2[i] == 1) {
        counter2++;
      }
    }

    cout << counter2-counter << endl;
  }
  return 0;
}

Measured memory_bytes: 4444
#include<iostream>

using namespace std;
int num[50];

int main(){
    
    int n,m;
    int a,b;
    cin >> n >> m;
    
    while(m--)
    {
        cin >> a >> b;
        num[a]++ ;
        num[b]++;
        
    }
    
    for(int i=1; i <=n; i++)
        cout << num[i] << endl;
    
    return 0;
   
}


Measured memory_bytes: 256
N = gets.to_i
As = gets.split.map(&:to_i)
target = As.sort
while (true) do
    tmp = []
    target[1..target.size].each{|x|
        n = x % target[0];
        tmp.push(n) if n != 0;
    }
    if tmp.size == 0
        ans = target[0]
        break;
    end
    target = tmp.push(target[0]).sort
end

puts ans


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

int main() {
    int N, M; cin >> N >> M;
    int left = 1, right = N;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        left = max(left, a);
        right = min(right, b);
    }
    cout << max(right - left + 1, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N,X;
    int *L;
    int D=0;
    int count=1;
    int i;
    cin >> N >> X;
    L = new int[N];
    for(i=0;i<N;i++){
        cin >> L[i];
    }
    for(i=0;i<N;i++){
        if( D + L[i] <= X){
            count++;
            D += L[i];
        }else{
            break;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int candy(int n) {
  int i = 0, sum = 0;
  while (i <= n) {
    sum += i;
    i++;
  }
  return sum;
}

int main(void) {
  int n;
  scanf("%d", &n);
  printf("%d\n", candy(n));
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using static System.Console;

namespace ConsoleAppAtCoderABC171
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];
            var p = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var min = p.OrderBy(x => x).Take(k).Sum();

            WriteLine(min);
        }
    }
}


Measured memory_bytes: 28752
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int n,m;
    long long ai,x;
    cin >> n >> m;
    priority_queue<long long> q;
    for(int i=0; i<n; i++){
        cin >> ai;
        q.push(ai);
    }
    for(int i=0; i<m; i++){
        x = q.top();
        q.pop();
        q.push(x/2);
    }
    long long s = 0;
    for(int i=0; i<n; i++){
        s += q.top();
        q.pop();
    }
    cout << s;
}

Measured memory_bytes: 1400
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long n,a,b,m,s=0,d;
  scanf("%lld %lld %lld %lld",&n,&a,&b,&m);
  while(--n){
    scanf("%lld",&d);
    s+=MIN((d-m)*a,b);
    m=d;
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

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

  map<string, int> m;
  for (int i = 0; i < n; i++) {
    m[s[i]]++;
  }

  int maxx = 0;
  for (pair<string, int> ms : m) {
    maxx = max(maxx, ms.second);
  }

  for (auto ms : m) {
    if (ms.second == maxx) {
      cout << ms.first << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 25472
//2018年  3月 26日 月曜日 23:51:34 JST-00:06:28
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];
ll SL[MAX_N], SR[MAX_N];

void pre(ll T[MAX_N]) {
	multiset<int> S;
	ll res = 0;
	rep(i, 0, 3 * N) {
		if(i < N) {
			S.insert(A[i]);
			res += A[i];
		}
		else {
			ll b = (*S.begin());
			if(b < A[i]) {
				S.erase(S.begin());
				S.insert(A[i]);
				res += A[i] - b;
			}
		}
		if(i >= N - 1) T[i] = res;
	}
}

void solve() {
	cin >> N;
	rep(i, 0, 3 * N) {
		cin >> A[i]; 
	}
	pre(SL);
	rep(i, 0, 3 * N) A[i] *= -1;
	reverse(A, A + 3 * N);
	pre(SR);
	reverse(SR, SR + 3 * N);
	// debug(vl(SL, SL + 3 * N));
	// debug(vl(SR, SR + 3 * N));
	ll res = -linf;
	rep(i, N - 1, 3 * N - N) {
		MAX(res, SL[i] + SR[i + 1]);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 12032
package main

import "fmt"

func main() {
	var (
		s, t, u string
		a, b    int
	)
	fmt.Scan(&s, &t, &a, &b, &u)

	m := make(map[string]int)
	m[s] = a
	m[t] = b
	if u == s {
		m[s]--
	} else {
		m[t]--
	}
	fmt.Println(m[s], m[t])
}


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

S = list(input())
a = int(S[0]+S[1])
b = int(S[2]+S[3])

if a >= 13 and b >= 13:
    print('NA')
elif a == 0 and b == 0:
    print('NA')
elif a == 0 and b >= 13:
    print('NA')
elif a == 0:
    print('YYMM')
elif b == 0 and a >= 13:
    print('NA')
elif b == 0:
    print('MMYY')
elif a >= 13:
    print('YYMM')
elif b >=13:
    print('MMYY')
else:
    print('AMBIGUOUS')


Measured memory_bytes: 3064