akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,L;
  cin >> N >> L;
  vector<int> a(N);
  int s = 0;
  //差の絶対値はりんごの絶対値
  for(int i=0;i<N;i++){
    a[i] = L+i;
    s += L+i;
  }
  int ans = 1e9;
  for(int i=0;i<N;i++){
    int t = s-a[i];
    if(abs(t-s) < abs(ans-s)) ans = t;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[20];
int d[20];
char str[20];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++)scanf("%d",c+i);
	for(int i=0;i<b;i++)d[c[i]]=1;
	for(int i=a;;i++){
		sprintf(str,"%d",i);
		bool ok=true;
		for(int j=0;str[j];j++)if(d[str[j]-'0'])ok=false;
		if(ok){
			printf("%d\n",i);return 0;
		}
	}
}

Measured memory_bytes: 128
import bisect
N = int(input())
arr = list(map(int,input().split()))
cnt = [[] for i in range(N + 1)]

for i in range(N):
    num = arr[i]
    cnt[num].append(i)

sunuke = []

for i in range(1,N + 1):
    if cnt[i] == []:
        break
    if i == 1:
        sunuke.append(cnt[1][0])
        continue
    else:
        j = bisect.bisect_left(cnt[i],sunuke[-1])
        if j == len(cnt[i]):
            break
        else:
            sunuke.append(cnt[i][j])
print(N - len(sunuke) if len(sunuke) > 0 else -1)

Measured memory_bytes: 43556
k=int(input())
ans=0
import math
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a

sumlis={}
for a in range(1,k+1):
    for b in range(1,k+1):
        t=math.gcd(a,b)
        for c in range(1,k+1):
            ans+=math.gcd(t,c)
                
print(ans)

Measured memory_bytes: 9212
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  sum = (sum + 4 * m - 1) / (4 * m);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += a[i] >= sum;
  }
  cout << (cnt >= m ? "Yes" : "No") << endl;

  return 0;
}


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

using namespace std;

#define FOR(I, A, B) for (int I = int(A); I < int(B); ++I)

const int N(105);
const double eps(1e-8);

struct Point {
	double x, y, z;
	Point(double _x = 0, double _y = 0, double _z = 0) {
		x = _x; y = _y; z = _z;
	}
	double m2() {
		return x * x + y * y + z * z;
	}
	void get() {
		scanf("%lf %lf %lf", &x, &y, &z);
	}
};

int n;
Point v, vv, s;
Point p[N];
double r[N];

Point operator+(Point a, Point b) {
	return Point(a.x + b.x, a.y + b.y, a.z + b.z);
}

Point operator-(Point a, Point b) {
	return Point(a.x - b.x, a.y - b.y, a.z - b.z);
}

Point operator*(Point a, double r) {
	return Point(a.x * r, a.y * r, a.z * r);
}
int dcmp(double x) {
	return fabs(x) < eps ? 0 : (x >= eps ? 1 : -1);
}
double sqr(double x) {return x * x;}
double dot(Point a, Point b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}
double cross(int i) {
	double A = v.m2(),
		   B = 2 * (v.x * (s.x - p[i].x) + v.y * (s.y - p[i].y) + v.z * (s.z - p[i].z)),
		   C = sqr(s.x - p[i].x) + sqr(s.y - p[i].y) + sqr(s.z - p[i].z) - sqr(r[i]);
	double delta = sqr(B) - 4 * A * C;
	if (dcmp(delta) <= 0) return 1e10;
	double t1 = (- B - sqrt(delta)) / 2 / A, t2 = (- B + sqrt(delta)) / 2 / A;
	if (dcmp(t1) <= 0) {
		if (dcmp(t2) <= 0) return 1e10;
		return t2;
	}
	return t1;
}
Point reflect(Point s, Point v, int i) {
	double len = dot(p[i] - s, v) / r[i];
	Point mid = (s - p[i]) * (len / r[i]); 
	return mid * 2 + v;
}
int main() {
	while (scanf("%d", &n), n) {
		s = Point(); v.get();
		FOR(i, 0, n) {
			p[i].get();
			scanf("%lf", &r[i]);
		}
		while (true) {
			double mint = 1e10;
			FOR(i, 0, n) {
				double tmp = cross(i);
				if (tmp < mint) {
					mint = tmp;
					vv = reflect(s + v * tmp, v, i);
				}
			}
			if (mint == 1e10) break;
			s = s + v * mint;
			v = vv;
		}
		printf("%.4lf %.4lf %.4lf\n", s.x, s.y, s.z);
	}
	return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
int A[MAX],n;
int partition(int, int);
int main(){
  int i,q;
  scanf("%d",&n);
  if(n < 1 || n > 100000)
    exit(1);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    if(A[i] < 0 || A[i] > 100000)
      exit(1);
  }

  q = partition(0,n-1);

  for(i = 0; i < n; i++){
    if(i)
      printf(" ");
    if(i == q)
      printf("[");
    printf("%d",A[i]);
    if(i == q)
      printf("]");
  }
  printf("\n");

  return 0;
}

int partition(int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int ans = 114514;

int eval(int n, int count)
{
    //cout << n << " " << count << " " << endl;
    if(ans<=count) return 0;
    if (n == 0)
    {
        ans = min(ans, count);
        return 0;
    }
    if (n < 0)
    {
        return 0;
    }

    if (9 <= n)
    {
        //9^nで引く
        int sq9 = 0;
        REP(i, 1, 10)
        {
            if (n < pow(9, i))
            {
                sq9 = pow(9, i - 1);
                break;
            }
        }
        eval(n - sq9, count+1);
    }
    if (6 <= n)
    {
        int sq6 = 0;
        REP(i, 1, 10)
        {
            if (n < pow(6, i))
            {

                sq6 = pow(6, i - 1);
                break;
            }
        }
        eval(n - sq6, count+1);
    }
    if (6 > n)
        eval(n - 1, count+1);
}

int main()
{
    int n;
    cin >> n;
    eval(n, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define X 2000010
ll fac[X],inv[X],ivf[X];
void initfac(){
	fac[0]=ivf[0]=inv[1]=1;
	for(ll i=1;i<X;i++){
		if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
		fac[i]=fac[i-1]*i%mod;
		ivf[i]=ivf[i-1]*inv[i]%mod;
	}
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll solve(ll h,ll w){
	ll ans=0;
	for(int i=1;i<=h+1;i++)ans=(ans+C(i+w,i))%mod;
	//cerr<<h<<" "<<w<<" "<<ans<<endl;
	return ans;
}
int main(){
	initfac();
	ll r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;
	r1--,c1--;
	ll ans=solve(r1,c1)+solve(r2,c2)-solve(r1,c2)-solve(r2,c1);
	ans%=mod;
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 47104
/* You can't hack me! */
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=998244353;
const ll MaxN=2000010;
const long double pi=3.14159265358979323846264338;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\ASISH\\Desktop\\coding\\input.txt", "r", stdin);
    freopen("C:\\Users\\ASISH\\Desktop\\coding\\output.txt", "w", stdout);
#endif

    ll T=1;
    // cin>>T;
    fo(q, T)
    {
        ll X, a, b;
        cin>>X;
        for(a=0; a<=200; a++){
            for(b=-200; b<=200; b++){
                if((ll)(pow(a, 5)-pow(b, 5))==X) break;
            }
            if((ll)(pow(a, 5)-pow(b, 5))==X) break;
        }
        os(a); on(b);
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
 int n,m;
 sl(n);sl(m);
 if(n==m)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> A){
    vll S(N+1, 0);
    REP(i, N){
        S[i+1] = S[i]+A[i];
    }
    map<ll, vll> rec;
    REP(i, N+1){
        if(rec.count(S[i]))
            rec[S[i]].push_back(i);
        else{
            rec[S[i]]=vll();
            rec[S[i]].push_back(i);
        }
    }
    ll ans = 0;
    for(auto x:rec){
        ll n = x.second.size();
        ans += n*(n-1)/2;
    }
    cout<<ans<<endl;
}

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


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

using namespace std;
vector<int> a;
int main()
{
    vector<int>::iterator low;
    int n,ans=0,in,l;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>in;
        a.push_back(in);
    }
    sort(a.begin(),a.end());
    for(int i=n-1; i>=0; i--){
        for(int j=i-1; j>=0; j--){
            low=upper_bound(a.begin(),a.end(),a[i]-a[j]);
            l=low-a.begin();
            ans+=max(j-l,0);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int hyou[14][14] = {0};

void judge(int ii, int jj) {
	int imove[4] = {0, 1, 0, -1};
	int jmove[4] = {1, 0, -1, 0};
	hyou[ii][jj] = 0;
	for (int i = 0; i < 4; i++) {
		if (hyou[ii+imove[i]][jj+jmove[i]] == 1) {
			judge(ii+imove[i], jj+jmove[i]);
		}
	}
	return;
}

void solve(void) {
	int counter = 0;
	for (int i = 1; i < 13; i++) {
		for (int j = 1; j < 13; j++) {
			if (hyou[i][j] == 1) {
				judge(i, j);
				counter++;
			}
		}
	}
	cout << counter << endl;
	return;
}

int main() {
	char a;
	while (cin >> a) {
		hyou[1][1] = a - '0';
		for (int j = 2; j < 13; j++) {
			cin >> a;
			hyou[1][j] = a - '0';
		}

		for (int i = 2; i < 13; i++) {
			for (int j = 1; j < 13; j++) {
				cin >> a;
				hyou[i][j] = a - '0';
			}
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, k;
ll arr[MAXN];
ll dp[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>k;
    dp[1] = 0;
    cin>>arr[1];
    for(ll i = 2; i <= n; i++){
        dp[i] = INF;
        cin>>arr[i];
        for(ll j = max(1LL, i - k); j < i; j++){
            dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
        }
    }
    cout<<dp[n]<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

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

const int B = 29;
unordered_map<long long, long long> mp;
long long ans;
string tmp;
int n;
long long ho(string &a, string &b) {
	long long h1 = 0, h2 = 0;
	for (int i = 0; i < a.size(); i++)
		h1 = h1 * B + a[i] - 'a' + 1;
	for (int i = 0; i < b.size(); i++)
		h2 = h2 * (B + 2) + b[i] - 'a' + 1;
	return (h1 * h2 + h1 + 2 * h2);
}

int main() {
	cin >> n >> tmp;
	for (int i = 0; i < (1 << n); i++) {
		string r1, r2;
		for (int j = 0; j < n; j++)
			if ((i & (1 << j)) != 0)
				r1.push_back(tmp[n + j]);
			else
				r2.push_back(tmp[n + j]);
		reverse(r2.begin(), r2.end());
		mp[ho(r1, r2)]++;
	}
	for (int i = 0; i < (1 << n); i++) {
		string r1, r2;
		for (int j = 0; j < n; j++)
			if ((i & (1 << j)) != 0)
				r1.push_back(tmp[j]);
			else
				r2.push_back(tmp[j]);
		reverse(r2.begin(), r2.end());
		ans += mp[ho(r2, r1)];
	}
	cout << ans;
}

Measured memory_bytes: 28788
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
int dx[2][2] = {{0,1},{0,-1}};
int dy[2][2] = {{1,1},{1,1}};

int main(){
  vector<int> vec[110];
  string s;
  int inde = 0;
int mex_size=0;
  while(cin >> s){
    
    for(int i=0;i<s.length();i++)if(s[i] == ',')s[i] = ' ';
    stringstream ss;
    ss << s;
    int cnt = 0;
    while(cnt < (ss.str()).size()){
      int val;
      if((ss >> val).fail())break;
      
      vec[inde].push_back(val);
      cnt++;
    }
    mex_size = max(mex_size,(int)vec[inde].size());
    inde++;
  }
 
  ll dp[inde][mex_size];
  rep(i,inde)rep(j,mex_size)dp[i][j] = -1;
  dp[0][0] = vec[0][0];
  int change = 0;
  rep(i,inde){

    if(vec[i].size() == mex_size)
      change = 1;
          
    rep(j,vec[i].size()){

      for(int k=0;k<2;k++){
	int nx = j+dx[change][k],ny = i+dy[change][k];
	if(!(0<=nx && nx < vec[ny].size() && 0<= ny && ny < inde))
	  continue;
		
	   dp[ny][nx] = max(dp[ny][nx],dp[i][j]+vec[ny][nx]);
      }      

    }
 
  }


    cout << dp[inde-1][0] << endl;

return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void Main() {
    string S; cin >> S;
    set<char> odd = {'R', 'U', 'D'};
    set<char> even = {'L', 'U', 'D'};
    rep(i, S.size()){
        if (i % 2 == 0){
            if (odd.find(S.at(i)) == odd.end()){
                cout << "No" << endl; exit(0);
            }
        } else {
            if (even.find(S.at(i)) == even.end()){
                cout << "No" << endl; exit(0);
            }

        }
    }
    cout << "Yes" << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        sv: [String; n]
    };

    let mut table = HashMap::new();
    for s in sv {
        *table.entry(s).or_insert(0) += 1;
    }
    let keys = vec![
        "AC".to_string(),
        "WA".to_string(),
        "TLE".to_string(),
        "RE".to_string(),
    ];
    for k in keys {
        let v = table.get(&k).unwrap_or(&0);
        println!("{} x {}", k, v);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 6792
#include<stdio.h>
int main()
{
    int ara[6]={'a','b','c','d','e'};
    int i,j,num;
    
   
    for(i=0;i<5;i++)
    {
       scanf("%d",&ara[i]);
    }
  
    for(i=0; i<5; i++)
    {
       for(j=i+1; j<5; j++)
       {
       	  if(ara[i] < ara[j])
           {
               num= ara[i] ;
               ara[i]= ara[j];
               ara[j]= num ;
           }
           
       }
    
      
       
    } 
     
    for(i=0;i<4;i++)  
    { 
       	printf("%d ",ara[i]); 
    }
    printf("%d\n",ara[4]);
    return 0;
}



Measured memory_bytes: 2040
import sys
iH,iW,iN = [int(_) for _ in input().split()]
aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

iMax = (iH - 2) * (iW -2)
#print (iMax)

dC={}
for i in range(10):
    dC[i]=0

#愚直 無理 つらい
#for i in range(1,iH -1):
#   for j in range(1,iW-1):
#       tmp = 0
#       for a in aD:
#           if j<= a[1] <=j+2 and i<= a[0] <= i+2:
#               tmp +=1
#       dC[tmp] +=1
dM = {}
for a in aD:
    y=a[0]
    x=a[1]
    for aP in [(y-2,x-2),(y-2,x-1),(y-2,x),(y-1,x-2),(y-1,x-1),(y-1,x),(y,x-2),(y,x-1),(y,x)]:
        if 0< aP[0]<iH-1 and 0 < aP[1] < iW-1:
            iP = aP[0]*iW + aP[1]
            if iP in dM:
                dM[iP] += 1
            else:
                dM[iP] = 1
for i in dM:
    dC[dM[i]]+=1

iAllBM=0
for i in range(1,10):
    iAllBM+=dC[i]
dC[0] = iMax -iAllBM

for i in range(10):
    print(dC[i])


Measured memory_bytes: 124132
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DR = { 1, 0, -1, 0 };
	static int[] DC = { 0, -1, 0, 1 };
	static int W, H, ans;
	static int[][] f;

	public static void main(String[] args) {
		while (true) {
			W = sc.nextInt();
			H = sc.nextInt();
			if (H == 0) break;
			f = new int[H][W];
			int startR = 0;
			int startC = 0;
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					int cell = sc.nextInt();
					if (cell == 2) {
						startR = i;
						startC = j;
						cell = 0;
					}
					f[i][j] = cell;
				}
			}
			ans = 11;
			dfs(startR, startC, 0);
			System.out.println(ans == 11 ? -1 : ans);
		}
	}

	static void dfs(int cr, int cc, int depth) {
		if (depth == 10 || depth >= ans) return;
		for (int i = 0; i < 4; ++i) {
			int nr = cr + DR[i];
			int nc = cc + DC[i];
			if (!inside(nr, nc)) continue;
			if (f[nr][nc] == 1) continue;
			while (true) {
				if (f[nr][nc] == 3) {
					ans = depth + 1;
					return;
				}
				nr += DR[i];
				nc += DC[i];
				if (!inside(nr, nc)) break;
				if (f[nr][nc] == 1) {
					f[nr][nc] = 0;
					dfs(nr - DR[i], nc - DC[i], depth + 1);
					f[nr][nc] = 1;
					break;
				}
			}
		}
	}

	static boolean inside(int r, int c) {
		return 0 <= r && r < H && 0 <= c && c < W;
	}

}

Measured memory_bytes: 36276
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    ll a,b,c,d ;
    cin >> a >> b >> c >> d ;

    cout << max(b*d,max(b*c,max(a*c,a*d)))  << endl ;
    return 0 ;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,start;
    cin >> n;
    start = ((n % 2 == 0)?0:1);
    vll a(n);
    rep(i,n)cin >> a[i];
    if(n == 1){
        cout << a[0] << endl;
        return 0;
    }
    for(int i=n-1;i>=0;i-=2)cout << a[i] << " ";
    for(int i=start;i<n;i+=2){
        if(i != n-2)cout << a[i] << " ";
        else cout << a[i] << endl;
    }
    return 0;
}

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

int main() {
  int k,a,b,i;
  cin >> k >> a >> b;
  for(i=a;i<=b;i++){
      if(i%k==0){
          cout << "OK" << endl;
          return 0;
      }
  }
  cout << "NG" << endl;
}

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

using namespace std;

using int64 = long long;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A > B) swap(A, B);
  if(A > C) swap(A, C);
  if(B > C) swap(B, C);
  cout << C * 10 + B + A << endl;
}



Measured memory_bytes: 764
#include <iostream>
#include <cstring>
using namespace std;
int s;
int z(int a,int b){
	if (a-b>=0){
		s=a-b;
	}
	else s=b-a;
	return s;
}
int main() {
	int x,a,b;
	cin>>x>>a>>b;
	if (z(a,x)<z(b,x)){
		cout<<"A"<<endl;
	}
	else cout<<"B"<<endl;
	
	return 0;
	

}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, m, k, d, w, summ;
string s, t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	ll a,b,c;
	cin >> a >> b >> c;

	if(a+b >= c) cout<<"Yes\n";
	else cout<<"No\n";
}

int main() {
	fastio; randomINT;
	//freopen("out_hc.txt","w+",stdout);
	//cin >> T;
	for (ll i = 1; i <= T; i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>
int main(void)
{
int a;
int b;

scanf("%d %d",&a,&b);

if(a > b)
 printf("a > b\n");

else if(a < b)
 printf("a < b\n");

else if(a == b)
 printf("a == b\n");

return 0;
}

Measured memory_bytes: 580
/**
 * マージソート
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()
}

class Main {

    companion object {

        private lateinit var inputs: List<Int>

        private var compareCount = 0

        fun init() {

            readLine()

            inputs = readLine()!!.split(" ").map { it.toInt() }

        }

        fun execute() {
            println(mergeSort(inputs).joinToString(" "))
            println(compareCount)
        }


        /**
         * 配列をまーじそーと。
         */
        fun mergeSort(list: List<Int>): List<Int> {

            if (list.size == 1) {
                return list
            }

            val mediumIndex = (list.size / 2.0).toInt()

            val sortList1 = if (mediumIndex == 1)
                arrayListOf(list[0])
            else mergeSort(list.subList(0, mediumIndex))

            val sortList2 = if (mediumIndex - list.size == 1)
                arrayListOf(list[mediumIndex])
            else mergeSort(list.subList(mediumIndex, list.size))

            val orderList = arrayListOf<Int>()

            var sortList1Index = 0
            var sortList2Index = 0
            while (orderList.size != (sortList1.size + sortList2.size)) {

                compareCount++

                /**
                 * 空の確認
                 */
                if (sortList2.size == sortList2Index) {
                    orderList.add(sortList1[sortList1Index])
                    sortList1Index++
                    continue
                } else if (sortList1.size == sortList1Index) {
                    orderList.add(sortList2[sortList2Index])
                    sortList2Index++
                    continue
                }

                /**
                 * 比較
                 */
                if (sortList1[sortList1Index] < sortList2[sortList2Index]) {
                    orderList.add(sortList1[sortList1Index])
                    sortList1Index++
                } else {
                    orderList.add(sortList2[sortList2Index])
                    sortList2Index++
                }
            }

            return orderList
        }
    }
}




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

int main() {
    string s;
    cin >> s;
    pair<int, int> p = { stoi(s.substr(5,2)),stoi(s.substr(8,2)) };
    if (p <= make_pair(4, 30))cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

using namespace std;

int N, F[103][12][4];

long long int P[103][12];

int c[103];

void CALC_c(int k) {

	int a[12];

	for (int n = 1; n <= 10; n++) {
		if (k % 2 == 1) { a[n] = 1; }
		else { a[n] = 0; }
		k /= 2;
	}

	for (int i = 1; i <= N; i++) { c[i] = 0; }


	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 5; j++) {
			for (int k = 1; k <= 2; k++) {
				if (F[i][j][k] == 1 && a[2 * j - 2 + k]) { c[i]++; }
			}
		}
	}

}

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 5; j++) {
			for (int k = 1; k <= 2; k++) {
				cin >> F[i][j][k];
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 10; j++) {
			cin >> P[i][j];
		}
	}

	//======================-

	long long int ans = -1000000000000;
	for (int k = 1; k < (1 << 10); k++) {
		CALC_c(k);
		long long int tmp = 0;
		for (int i = 1; i <= N; i++) {
			tmp += P[i][c[i]];
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    int N;
    string S;
    bool flg = true;
    cin >> N >> S ;
    int a = N/2;
    if(N%2!=0){cout << "No" << endl; return 0;}
    rep(i,a){
        if(S[i]!=S[i+(a)]){
            flg = false;
        }
    }
    if(flg == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

void solve() {
    string s;
    cin >> s;
    int cnt = 0;
    for (char ch : s) {
        cnt += ch - '0';
    }
    cout << ((cnt % 9 == 0) ? "Yes" : "No") << "\n";
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  char a, b;
  std::cin >> a >> b;
  if (a == 'H')
    std::cout << b << std::endl;
  else
    std::cout << (b == 'H' ? 'D' : 'H') << std::endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'I') {
            sum++;
        }
        else {
            sum--;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
s = input()
i = len(s)

def palindrome(ss):
    if ss == ss[::-1]:
        return 1
    else:
        return 0

if palindrome(s) == 1 and palindrome(s[:int((i - 1) / 2)]) == 1 and palindrome((s[int((i + 3) / 2) - 1:i])) == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli h,w,d;
    cin>>h>>w>>d;
    map<lli,pii> ma,prev;
    vi cost(h*w+10);
    rep(i,h)rep(j,w){
        lli k;
        cin>>k;
        ma[k]=pii(i+1,j+1);
    }
    int q;
    cin>>q;
    for(lli i=h*w;i>0;i--){
        if(i+d>h*w) cost[i]=0;
        else{
            cost[i]=cost[i+d]+abs(ma.at(i).first-ma.at(i+d).first)+abs(ma.at(i).second-ma.at(i+d).second);
        }
    }
    rep(i,q){
        lli l,r;
        cin>>l>>r;
        out(cost[l]-cost[r]);
    }
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}
double dist(int i, int j, vector<double>&x, vector<double>&y ){
    return sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
}

int make_strings(vector<string>&S, string str, int N){
    if(str.size()==N){
        S.push_back(str);
        return 0;
    }
    for(int i=1;i<N+1;i++){
        int flag=0;
        for(int j=0;j<str.size();j++){
            if(charToInt(str.at(j))==i)flag=1;
        }
        if(flag==1)continue;
        string str_temp = str+to_string(i);
        make_strings(S, str_temp, N);
    }
    return 0;
}

signed main(){
    int N; cin>>N;
    vector<double> x(N),y(N);
    rep(i,N)cin>>x.at(i)>>y.at(i);

    vector<string> S;
    make_strings(S, "", N);

 /*   for(auto str : S){
        cout<<str<<endl;
    }*/
    double tot_distance = 0;
    for(auto str : S){
//        cout<<tot_distance<<endl;
        for(int i=1;i<N;i++){
            int start = charToInt(str.at(i-1))-1;
            int end = charToInt(str.at(i))-1;
            tot_distance += dist(start,end,x,y);
        }
    }
    printf("%.10lf\n",tot_distance/S.size());

    return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>istream&operator>>(istream&is,pair<T,U>&P){is>>P.fst;is>>P.snd;return is;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}

void Main() {
  ll s = read<ll>();
  ll c = read<ll>();

  if (s * 2 >= c) {
    cout << c / 2 << endl;
  }
  else {
    // s * 2 < c
    ll a = s;
    c -= s * 2;
    a += c / 4;
    cout << a << endl;
  }
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,c,n = inpl()
res = 0
for i in range(3001):
    for j in range(3001):
        tmp = n - (i*a + j*b)
        if tmp < 0:
            break
        if tmp % c == 0:
            res += 1
print(res)

Measured memory_bytes: 40812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 要素数nを読み込み、配列にn個の整数を読み込む
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = a.length - 1; i >= 0; i--) {
            System.out.printf("%d", a[i]);
            if (i != 0) {
                System.out.printf(" ");
            }
        }
        // 以下で配列aの中身を逆順に表示しよう
        // 改行なしで表示する時は System.out.print(表示する値) を使おう
        // 改行だけを表示する時は System.out.println() を使おう
        sc.close();
        System.out.printf("\n");
    }
}


Measured memory_bytes: 26596
n=int(input())
t=input().split()
#n==len(t)
m=int(input())
px=[]
for i in range(m):
  px.append(input().split())
res=0
for j in range(1,m+1):
  for k in range(1,n+1):	
    if k==int(px[j-1][0]):
      res+=int(px[j-1][1])
      #print(12345)
    else:
      res+=int(t[k-1])
      #print('drink')
  print(res)
  res=0

Measured memory_bytes: 3064
(* unihernandez22
 * https://atcoder.jp/contests/abc054/tasks/abc054_b
 * implementation
 * *)

Scanf.scanf "%d %d\n" @@ fun n m ->
    let a = Array.init n @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
    let b = Array.init m @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in

    let valid = ref true in
    let ans = ref "No\n" in
    for i = 0 to n-m do
        for j = 0 to n-m do
            valid := true;
            for y = 0 to m-1 do
                if String.sub a.(i+y) j m <> b.(y) then
                    valid := false;
            done;
            if !valid then
                ans := "Yes\n";
        done;
    done;
    print_string !ans;;



Measured memory_bytes: 4272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long long gcd(long long a,long long b){long long r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}
long long lcm(long long a,long long b){long long r;r = gcd(a,b);r = a / r * b;return r;}

int main()
{
    long long n,m,i;
    char s[100001],t[100001];
    scanf("%lld %lld %s %s",&n,&m,s,t);

    long long l = lcm(n,m);
    long long r = lcm(l / n,l / m);

        for (i = 0; i < l / r; i++)
        {
            if(s[i * r * n / l] != t[i * r * m / l])break;
        }
        if(i != l / r)printf("-1");
        else printf("%lld",l);

}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	long go(int[] a, int y) {
		long ret = 0;
		for (int x : a) {
			ret += (x - y) * (x - y);
		}
		return ret;
	}

	void solve() throws IOException {
		int n = nextInt();
		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			sum += a[i];
		}
		
		int avg = Math.floorDiv(sum, n);
		out.println(Math.min(go(a, avg), go(a, avg + 1)));
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

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

int main(){
  int t[101],n,s;
  vector<int> r;
  while(1){
    scanf("%d,%d",&n,&s);
    if(n==0&&s==0) break;
    t[n]=s;
    r.push_back(s);
  }
  sort(r.begin(),r.end());
  r.erase(unique(r.begin(),r.end()),r.end());
  while(scanf("%d",&n)>0){
    printf("%d\n",r.end()-find(r.begin(),r.end(),t[n]));
  }
  return 0;
}

Measured memory_bytes: 1060
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def main():
    n = ri()
    s = input()
    ns = ""
    for c in s:
        ns += alp[(ord(c)-ord('A')+n)%26]
    print(ns)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    double a,b;
    cin>>a>>b;
    cout<<(int)ceil((a+b)/2.0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <math.h>
#include <limits.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		s.insert(k);
	}
	if (s.size() == n) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define Get(x,y) scanf("%I64d%I64d",&x,&y);
#define get(x) scanf("%I64d",&x);
#define Gett(x,y) scanf("%d%d",&x,&y);
#define gett(x) scanf("%d",&x);																																														
#define f(i,a,b) for(int i=a;i<b;i++)
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define ll long long
#define pb push_back
#define maxm(a,b) a=max(a,b);
#define minm(a,b) a=min(a,b);
#define S second
#define F first
const int N=3005;
ll n,m,a[N],dp[N],mod=998244353,ans;
int main(){
	cin>>n>>m;
	f(i,1,n+1){
		cin>>a[i];
		if(a[i]<m)
			ans=(ans+dp[m-a[i]]*(n-i+1))%mod;
		if(a[i]==m)
			ans=(ans+i*(n-i+1))%mod;
		f_(j,N-2,a[i]+1)
			dp[j]=(dp[j]+dp[j-a[i]])%mod;
		dp[a[i]]=(dp[a[i]]+i)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
 int a, b, c, sum;
 cin >> a >> b >> c;
 if (a<c && b<c) {
  sum = a + b;
 } else if (a<b && c<b) {
  sum = a + c;
 } else {
  sum = b + c;
 }
 cout << sum << endl;
 return 0;
}

Measured memory_bytes: 256