akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    vi x(n),y(n);
    rep(i,n)cin >> x[i] >> y[i];
    int ans = n;
    rep(i,n)rep(j,n)if(i != j){
        int p = x[i] - x[j];
        int q = y[i] - y[j];
        int cnt = 0;
        rep(k,n)rep(l,n)if(k != l){
            if(x[k] - x[l] == p && y[k] - y[l] == q)cnt++;
        }
        ans = min(ans, n-cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<int> a(n);
    read(a);
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0 && a[i] % 2) {
            res++;
        }
    }
    cout << res << newl;
}

Measured memory_bytes: 3612
# E - Crested Ibis vs Monster
INF = 100000000
H,N = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
c = [INF]*H+[0]
for i in range(N):
    A,B = ab[i]
    for h in range(H,0,-1):
        k = max(0,h-A)
        c[k] = min(c[k], c[h]+B)
print(c[0])

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

int main()
{
	int n, T[10000], q, S[500];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> T[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> S[i];
	}
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		T[n] = S[i];
		int j = 0;
		while (T[j] != S[i]) {
			j++;
		}
		if (j != n) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3112
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll x(n), l(n);
  vp p;
  rep(i, n){
    cin >> x[i] >> l[i];
    p.emplace_back(x[i]+l[i], x[i]-l[i]);
  }
  sort(ALL(p));
  ll rgt = -INF;
  ll ans = 0;
  rep(i, n){
    if(p[i].second >= rgt){
      ans++;
      rgt = p[i].first;
    }
  }
  print(ans);
}


Measured memory_bytes: 3956
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
 
int main(int argc, char *argv[])
{
  int *x, *y;
  int n, i;
  double D[4];
 
  for (i = 0; i < 4; i++) D[i] = 0.0;
 
  scanf("%d", &n);
 
  x = (int *)malloc(sizeof(int) * n);
  y = (int *)malloc(sizeof(int) * n);
 
  for (i = 0; i < n; i++) scanf("%d", &x[i]);
  for (i = 0; i < n; i++) scanf("%d", &y[i]);
 
  for (i = 0; i < n; i++) {
    D[0] += abs(x[i] - y[i]);
    D[1] += (x[i] - y[i]) * (x[i] - y[i]);
    D[2] += abs((x[i]-y[i]) * (x[i]-y[i]) * (x[i]-y[i]));
    if (D[3] < abs(x[i] - y[i])) D[3] = abs(x[i] - y[i]);
  }
  D[1] = sqrt(D[1]);
  D[2] = cbrt(D[2]);
 
  for (i = 0; i < 4; i++) {
    printf("%f\n", D[i]);
  }
 
  free(x);
  free(y);
 
  return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>

int main(){
    long i;
    long a, b, v, w, t;
    long s;

    scanf("%ld%ld%ld%ld%ld", &a, &v, &b, &w, &t);

    s = (a > b) ? (a - b):(b - a);

    for(i = 0;i < t;i++){
        s = s + w - v;
        if(s <= 0){
            puts("YES");
            return 0;
        }
    }

    puts("NO");

    return 0;
}

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

int P[101][11];
int F[101][10];
int n;
int res = -2e9;

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

	cin >> n;

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

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

	for(int i=1;i<(1<<10);i++)
	{
		int count[101];
		memset(count,0,sizeof(count));

		for(int j=0;j<10;j++)
		{
			if(i&(1<<j))
			{
				for(int k=1;k<=n;k++)
				{
					if(F[k][j]==1)
					{
						count[k]++;
					}
				}
			}
		}
		
		int sum = 0;
		for(int j=1;j<=n;j++)
		{
			sum += P[j][count[j]];
		}

		res = max(res,sum);
	}

	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100000
int d[N], b[N], c[N], a[N];

int main(){
	int n, m;
	cin>>n>>m;
	rep(i, n) cin>>d[i];
	c[0] = d[0]; a[n-1] = d[n-1];
	rep(i, n-1) c[i+1] = min(c[i], d[i+1]);
	rep(i, n-1) a[i] = max(a[i+1], d[i]);
	rep(i, n) b[i] = max(d[i]-c[i], a[i]-d[i]);
	ll w = 0;
	rep(i, n) chmax(w, b[i]);
	ll res = 0, mn = d[0], cnt1 = 0, cnt2 = 0;
	for(ll i = 0; i < n; i++){
		if(d[i]==mn){
			cnt1++;
		} else if(d[i]<mn){
			res += min(cnt1, cnt2);
			cnt1 = 1; cnt2 = 0;
			mn = d[i];
		} else if(d[i]-mn==w){
			cnt2++;
		}
	}
	res += min(cnt1, cnt2);
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
int n;
long long p[200001], xop[200001], ans, a[200001];
int main (){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        p[i] = p[i - 1] + a[i];
        xop[i] = (xop[i - 1]^a[i]);
    }
    for(int i = 1; i <= n; i++){
        int l = i, r = n;
        while(r - l > 1){
            int mid = (r + l) / 2;
            if(p[mid] - p[i - 1] == (xop[mid]^xop[i - 1])){
                l = mid;
            }
            else{
                r = mid;
            }
        }
        if(p[r] - p[i - 1] == (xop[r]^xop[i - 1])){
            ans += (r - i + 1);
        }
        else{
            ans += (l - i + 1);
        }
    }
    cout << ans;
}


Measured memory_bytes: 4992
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int i;
      int AC = 0;
      int TLE = 0;
      int RE = 0;
      int WA = 0;
      String ac = "AC";
      String temp = sc.nextLine();
      for(i=0;i<N;i++)
      {
          String s = sc.nextLine();
          if(s.equals("AC"))
          {
            AC++;
          }
          else if(s.equals("WA"))
            WA++;
          else if(s.equals("TLE"))
            TLE++;
          else if(s.equals("RE"))
            RE++;
      }
      System.out.println("AC"+" x "+AC);
      System.out.println("WA"+" x "+WA);
      System.out.println("TLE"+" x "+TLE);
      System.out.println("RE"+" x "+RE);
    }
}

Measured memory_bytes: 51420
#include"iostream"
#include"map"
using namespace std;
int main(void) {
	int a;
	cin >> a;
	string tmp;

	map<string, int> mp;
	for (int i = 0; i < a; i++) {
		cin >> tmp;
		if (mp[tmp] == 0) {
			mp[tmp] = 1;
		}
		else {
			auto itr = mp.find(tmp);
			itr->second = itr->second + 1;
		}
	}
	int max = 0 ;

	for (auto i = mp.begin(); i != mp.end(); ++i) {
		if (i->second > max) {
			max = i->second;
		}
	}

	for (auto i = mp.begin(); i != mp.end(); ++i) {
		if (i->second == max) {
			cout << i->first << endl;
		}
	}


}


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

int n,l[110];

int main() {
	cin>>n;
	for(int i=1;i<=n;++i)
		scanf("%d",&l[i]);
	
	int ans=0;
	for(int i=1;i<=n-2;++i)
		for(int j=i+1;j<=n-1;++j)
			for(int k=j+1;k<=n;++k)
				if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]
				&& l[i]+l[j]>l[k]
				&& l[j]+l[k]>l[i]
				&& l[k]+l[i]>l[j])
					++ans;
	
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,k; cin >> n >> k;
  vector<int> h(n); rep(i,n) cin >> h[i];

  sort(h.begin(),h.end());
  ll ans = 0;
  rep(i,n-k) ans+=h[i];

  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 4032
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll H, W, A, B;
  cin>>H>>W>>A>>B;
  H--;
  W--;
  ll ue[H+W+1];
  ue[0] = 1;
  for(ll i=1;i<=H+W;++i){
    ue[i] = ue[i-1]*i%mod;
  }
  ll ans = ue[H+W];
  ll h = mod - 2;
  ll shita1=1, shita2=1, shita3=1, shita4=1;
  ll tmpshita1, tmpshita2, tmpshita3, tmpshita4;
  ll two;
  while(h>0){
    tmpshita1 = ue[H];
    tmpshita2 = ue[W];
    two = 1;
    while(2*two<=h){
      two *= 2;
      tmpshita1 *= tmpshita1;
      tmpshita1 %= mod;
      tmpshita2 *= tmpshita2;
      tmpshita2 %= mod;
    }
    h -= two;
    shita1 *= tmpshita1;
    shita1 %= mod;
    shita2 *= tmpshita2;
    shita2 %= mod;
  }
  ans = ans*shita1%mod*shita2%mod;
  ll tmpans;
  for(ll i=0;i<B;++i){
    tmpans = ue[H-A+i]*ue[W+A-i-1]%mod;
    shita1 = 1;
    shita2 = 1;
    shita3 = 1;
    shita4 = 1;
    h = mod - 2;
    two = 1;
    while(h>0){
      two = 1;
      tmpshita1 = ue[i];
      tmpshita2 = ue[H-A];
      tmpshita3 = ue[W-i];
      tmpshita4 = ue[A-1];
      while(2*two<=h){
        two *= 2;
        tmpshita1 *= tmpshita1;
        tmpshita2 *= tmpshita2;
        tmpshita3 *= tmpshita3;
        tmpshita4 *= tmpshita4;
        tmpshita1 %= mod;
        tmpshita2 %= mod;
        tmpshita3 %= mod;
        tmpshita4 %= mod;
      }
      h -= two;
      shita1 *= tmpshita1;
      shita2 *= tmpshita2;
      shita3 *= tmpshita3;
      shita4 *= tmpshita4;
      shita1 %= mod;
      shita2 %= mod;
      shita3 %= mod;
      shita4 %= mod;
    }
    tmpans = tmpans*shita1%mod*shita2%mod*shita3%mod*shita4%mod;
    ans = (ans-tmpans+mod)%mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;


int main(){
    long long x,y;
    cin >> x >> y;
    int cnt=0;
    while(x<=y){
        ++cnt;
        x*=2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    vector<pair<ll,ll>> a(N),b(N);
    rep(i,0,N){
        cin>>a[i].first>>a[i].second;
    }
    rep(i,0,N){
        cin>>b[i].first>>b[i].second;
    }
    sort(all(a));
    sort(all(b));
    ll ans = 0;
    rep(i,0,N){
        ll max_a = -1;
        ll ind =-1;
        rep(j,0,a.size()){
            if(a[j].first < b[i].first){
                if(a[j].second < b[i].second){
                    if(a[j].second > max_a){
                        ind = j;
                        max_a = a[j].second;
                    }
                }
            }
        }
        if(max_a != -1){
            a.erase(a.begin()+ind);
            ans++;
        }
    }
    cout<<ans;

    return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n%2==1){
        cout << b[n/2]-a[n/2]+1 << endl;
    }else{
        ll x,y;
        x=a[n/2-1]+a[n/2];
        y=b[n/2-1]+b[n/2];
        cout << y-x+1 << endl;
    }
    
    return 0;
}











Measured memory_bytes: 6428
n, m = map(int, input().split())
red = {1, }
l = [1 for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    l[x - 1] -= 1
    l[y - 1] += 1
    if x in red:
        red.add(y)
        if l[x - 1] == 0:
            red.discard(x)
print(len(red))


Measured memory_bytes: 18236
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int n = S.length();
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		int[] a = new int[26];
		int[] b = new int[26];
		for(int i = 0; i < n; i ++) {
			a[s[i]-97] += 1;
			b[t[i]-97] += 1;
		}
		Arrays.sort(a);
		Arrays.sort(b);
		for(int i = 0; i < 26; i++) {
			if(a[i] != b[i]) {
				System.out.println("No");
				break;
			}
			else if(i == 25)
				System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 28732
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), end(x)+(n)
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) (((a%MOD+MOD)%MOD-(b%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


string S;
int dx[] = { -1, 1, -4, 4 };
queue<pair<string, int>> q;
unordered_map<string, int> d;

signed main(){
    q.push({ "01234567", 0 });
    d["01234567"] = 0;
    while(!q.empty()){
        auto s = q.front(); q.pop();
        int x = s.second;
        rep(i, 0, 4){
            int X = x+dx[i];
            if(!isin(X, 0, 8)) continue;
            if(min(x, X) == 3 && max(x, X) == 4) continue;
            auto s2 = s.first;
            s2[x] = s.first[X]; s2[X] = s.first[x];
            if(d[s2] != 0) continue;
            d[s2] = d[s.first]+1; q.push({ s2, X });
        }
    }
    while(getline(cin, S)){
        S.erase(remove_if(ALL(S), [](char c){ return c == ' '; }), end(S));
        cout << d[S] << endl;
    }

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include<string>
using namespace std;
bool squares[6][6];
bool painted_i[6];
bool painted_j[6];

int H,W,K;
int num_of_black(){
    int cnt = 0;
    for(int i=0;i<H;i++){
        if(painted_i[i]){
            continue;
        }
        for(int j=0;j<W;j++){
            if(painted_j[j]){
                continue;
            }
            if(squares[i][j] == true){
                cnt++;
            }
        }
    }
    return cnt;
}

int backtrack(int i, int j, int i_step, int j_step, int i_selected, int j_selected){

    if(i_selected==i && j == j_selected){
        return num_of_black()==K ? 1 : 0;
    }

    if(j_step>=W){
        return 0;
    }
    int sum = 0;
    if(i_selected == i){
        painted_j[j_step] = true;
        sum += backtrack(i,j,i_step,j_step+1,i_selected,j_selected+1);
        painted_j[j_step] = false;
        sum += backtrack(i,j,i_step,j_step+1,i_selected,j_selected);
        return sum;
    }
    
    if(i_step>=H){
        return 0;
    }

    painted_i[i_step] = true;
    sum += backtrack(i,j,i_step+1,j_step,i_selected+1,j_selected);
    painted_i[i_step] = false;
    sum += backtrack(i,j,i_step+1,j_step,i_selected,j_selected);
    return sum;

}

int main() {
    cin>>H>>W>>K;
    for(int i=0;i<H;i++){
        string s;
        cin>>s;
        for(int j=0;j<W;j++){
            squares[i][j] = (s[j]=='#');
        }
    }

    for(int i=0;i<6;i++){
        painted_i[i] = false;
    }
    for(int j=0;j<6;j++){
        painted_j[j] = false;
    }

    int cnt = 0;
    for(int i=0;i<=H;i++){
        for(int j=0;j<=W;j++){
            cnt += backtrack(i,j,0,0,0,0);
            //cout<<"i: "<<i<<" j: "<<j<<" "<<backtrack(i,j,0,0,0,0)<<"\n";
        }
    }
    cout<<cnt;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define mod 998244353


ll n;
ll a[100100];

int main(){
  ll res0=0;
  cin >> n;
  rep(i,n){
    cin >> a[i];
    if(a[i]<=0)res0++;
  }
  sort(a,a+n);
  ll ans=0,a1=0,a2=0;

  rep(i,n){
    if(i<res0/2*2){
      a1-=a[i];
    }else{
      a1+=a[i];
    }
  }
  if((res0/2*2+1)<n){
    rep(i,n){
      if(i<=1+res0/2*2){
        a2-=a[i];
      }else{
        a2+=a[i];
      }
    }
  }
  ans=max(a1,a2);
  cout << ans <<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int N;  cin >> N;
  string s;  cin >> s;

  bool ans = true;
  if(N % 2 == 0){
    for(int i = 0 ; i < N / 2 ; i++){
      if(s[i] != s[i + N / 2])  ans = false;
    }
  }else{
    ans = false;
  }

  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lol long long
int main(){
  lol a,b,c;
  cin>>a>>b>>c;
  if(a+b<=c) cout<<"0 0\n";
  else{
    if(a<=c){
      cout<<"0 "<<b+a-c<<"\n";
    }
    else cout<<a-c<<" "<<b<<"\n";
  }
  return(0);
}


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

public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    System.out.println(s.equals("ABC")?"ARC":"ABC");
  }
}

Measured memory_bytes: 32528
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int s, w; cin >> s >> w;
    if (s > w) puts("safe");
    else puts("unsafe");
    return 0;
}

Measured memory_bytes: 3528
n = int(input())
m = n + 1
sum = 0
if m <= 3:
  for x in range(m):
    sum = sum + x
else:
  for x in range(m):
    if x%3 == 0 or x%5 == 0:
      pass
    else:
      sum = sum + x
print(sum)

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

using namespace std;

const int MOD = 1e9 + 7;

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = r * r % MOD;
    if (b&1) return r * a % MOD;
    return r;
}

int add (int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

int mul (int a , int b) {
    return a * 1ll * b % MOD;
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
    freopen("input.in" , "r" , stdin);
#endif
    int n , k;
    cin >> n >> k;

    int ans = 0;

    vector<int> ways(k + 1);
    for (int i = k ;i >= 1 ;i--) {
        ways[i] = power(k / i , n);
        for (int m = i + i ; m <= k ; m += i)
            ways[i] = add(ways[i] , -ways[m]);

        ans = add(ans , mul(ways[i] , i));
    }

    cout << ans;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
  ll n; cin>>n;
  vector<double>v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  double ans=v[0];
  rep(i,n-1){
  ans=(ans+v[i+1])/2;
  }
  cout << fixed << setprecision(9)<<ans<<endl;;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    ll a, b, c, d, temp;
    cin >> a >> b >> c >> d;
    if(c < d){
        swap(c, d);
    }
    ll a1 = c, b1 = d, r = c % d, x = c * d;
    while(r != 0){
        a1 = b1;
        b1 = r;
        r = a1 % b1;
    }
    ll lcm = x / b1;
    ll ans = b - a + 1;
    ans -= b / c - a / c;
    ans -= b / d - a / d;
    ans += b / lcm - a / lcm;
    if(a % c == 0) ans--;
    if(a % d == 0) ans--;
    if(a % lcm == 0) ans++;

    print(ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
int main()
{
    int a[12], b[12];
    char buf[256];
    while (fgets(buf, 256, stdin)) {
        char* p = strtok(buf, " ");
        int L = atoi(p);
        int n = 0;
        while (p = strtok(NULL, " ")) a[n++] = atoi(p);
        std::sort(a, a + n);
        bool ok = false;

        b[n/2] = a[0];
        int i = 0, j = 1, k = 1, l = 1;
        while (i < n) {
            if (i % 4 == 0) { b[n/2+k] = a[n-l]; l++; }
            if (i % 4 == 1) { b[n/2-k] = a[n-l]; l++; k++; }
            if (i % 4 == 2) { b[n/2+k] = a[j]; j++; }
            if (i % 4 == 3) { b[n/2-k] = a[j]; j++; k++; }
            i++;
        }
        double t = b[0];
        REP(i, 1, n) t += 2 * sqrt(b[i-1] * b[i]);
        t += b[n-1];
        if (!(t > L)) ok = true;

        puts(ok ? "OK" : "NA");
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[32][32];
ll sum[3][32];
int main() {
	ll n,c;
	cin>>n>>c;
	for(ll i=0;i<c;i++){
		for(ll j=0;j<c;j++){
			ll now;
			cin>>now;
			ch[i][j]=now;
		}
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			ll now;
			cin>>now;
			now--;
			ll now1=(i+j)%3;
			sum[now1][now]++;
		}
	}
	ll ans=INF;
	for(ll i=0;i<c;i++){
		for(ll j=0;j<c;j++){
			for(ll k=0;k<c;k++){
				ll sum1=0;
				if(i==j||j==k||k==i){
					continue;
				}
				for(ll l=0;l<3;l++){
					for(ll m=0;m<=c;m++){
						if(l==0){
							sum1+=sum[l][m]*ch[m][i];
						}
						else if(l==1){
							sum1+=sum[l][m]*ch[m][j];
						}
						else{
							sum1+=sum[l][m]*ch[m][k];
						}
					}
				}
				ans=min(ans,sum1);
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
N, M = list(map(int,input().split()))
X = list(map(int,input().split()))
X = sorted(X)
diff = []
for i in range(M - 1):
    diff.append(abs(X[i] - X[i + 1]))
    
diff = sorted(diff)[::-1]
ans = sum(diff[N - 1:])
print(ans)

Measured memory_bytes: 93024
import math
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(1, math.floor(N / 2 + 1)):
    Alice += max(a)
    a.remove(max(a))
    Bob += max(a)
    a.remove(max(a))
if N %2 != 0:
    Alice += max(a)
print(Alice - Bob)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> m;
  rep(i,n){
    cin >> a.at(i);
    if(m.count(a.at(i)))m[a.at(i)]++;
    else m[a.at(i)] = 1;
  }
  ll ans = 0;
  for(auto p : m){
    
    ll count = p.second;
    //cout<<num<<" "<<count<<endl;

    if(count<2)continue;
    ans+=(count*(count-1))/2;
  }
  //cout<<ans<<endl;
  
  rep(i,n){
    ll tmpans = ans;
    ll dif = m[a.at(i)];//含まれている個数
    if(dif==2)tmpans--;
    else if(dif>2)tmpans-=(dif-1);
    cout<<tmpans<<endl;
  }
  return 0;
  
}


Measured memory_bytes: 11008
// AOJ 	2529: Brainf*ck
// 2018.2.7 bal4u
 
#include <stdio.h>
#include <math.h>

#define ABS(a)	((a)>=0?(a):-(a))

char s[1003];
int memo[16];
char c4d[2] = {'-','+'};
char c4k[2] = {'<','>'};

void pr(char *s) { while (*s) putchar(*s++); }

int main()
{
	int i, k, pk, d, b, f;
	char *p;

	fgets(s, 1003, stdin);
	putchar('>');
	k = 0;
	for (p = s; *p > ' '; p++) {

		pk = k, k = 0;
		for (i = 0; i < 16; i++) {
			if (ABS(memo[k] - *p) > ABS(memo[i] - *p)) k = i;
		}

		i = ABS(k-pk); f = (k>pk); while (i--) putchar(c4k[f]), putchar(c4k[f]);

		d = *p - memo[k], b = (int)sqrt(ABS(d));
		memo[k] = *p;

        if (ABS(d) < 8) {
			i = ABS(d);	f = (d>0); while (i--) putchar(c4d[f]);
		} else {
			putchar('<');
			i = ABS(d)/b; while (i--) putchar('+');
			pr("[>");
			i = b; f = (d>0); while (i--) putchar(c4d[f]);

			pr("<-]>");
			i = ABS(d)-b*(ABS(d)/b), f = (d>0); while (i--) putchar(c4d[f]);
		}
		putchar('.');
	}
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
using pil = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
#define MOD 1000000007
#define MOD2 998244353

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    int a;
    cin >> n;
    vector<int> ans(n,0);
    for(int i = 1; i < n; i++){
        cin >> a;
        ans[a - 1]++;
    }
    for(int i = 0; i < n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000
#define ll long long
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> T;
map<P,vector<T>> e;
map<P,bool> visit;
map<P,int> dist;
int n,m;
int main(){
    cin>>n>>m;
    int p,q,c;
    rep(i,m){
        cin>>p>>q>>c;
        p-=1;q-=1;
        if(e.find(make_pair(p,c))==e.end()) e[make_pair(p,c)]={};
        if(e.find(make_pair(q,c))==e.end()) e[make_pair(q,c)]={};
        e[make_pair(p,c)].push_back(make_pair(0,make_pair(q,c)));
        e[make_pair(q,c)].push_back(make_pair(0,make_pair(p,c)));
        e[make_pair(p,c)].push_back(make_pair(1,make_pair(p,-1)));
        e[make_pair(q,c)].push_back(make_pair(1,make_pair(q,-1)));
        e[make_pair(p,-1)].push_back(make_pair(0,make_pair(p,c)));
        e[make_pair(q,-1)].push_back(make_pair(0,make_pair(q,c)));
        dist[make_pair(p,c)]=INF;
        dist[make_pair(q,c)]=INF;
    }
    rep(i,n) dist[make_pair(i,-1)]=INF;

    priority_queue<T, vector<T>, greater<T>> que;
    que.push(make_pair(0,make_pair(0,-1)));
    while(!que.empty()){
        T x=que.top();
        que.pop();
        visit[x.second]=true;
        dist[x.second]=x.first;
        for (auto y:e[x.second]){
            if (!visit[y.second]){
                if (dist[y.second]>x.first+y.first){
                    que.push(make_pair(x.first+y.first,y.second));
                    dist[y.second]=x.first+y.first;
                }
            }
        }
    }
    int d=dist[make_pair(n-1,-1)];
    if (d<INF) cout<<d<<endl;
    else cout<<-1<<endl;
    
    return 0;
}

Measured memory_bytes: 106680
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>

using namespace std;

struct frac {
	long long x;
	long long y;

	static long long gcd(long long a, long long b) {
		if (a < 0) {
			a *= -1;
		}
		while (b != 0) {
			long long tmp = a;
			a = b;
			b = tmp % b;
		}
		return a;
	}

	frac(long long x = 0, long long y = 1) {
		if (y < 0) {
			x *= -1;
			y *= -1;
		}
		long long g = gcd(x, y);
		this->x = x / g;
		this->y = y / g;
	}
};


frac operator+(frac a, frac b) { return frac(a.x * b.y + b.x * a.y, a.y * b.y); }
frac operator-(frac a, frac b) { return frac(a.x * b.y - b.x * a.y, a.y * b.y); }
frac operator*(frac a, frac b) { return frac(a.x * b.x, a.y * b.y); }
frac operator/(frac a, frac b) { return frac(a.x * b.y, a.y * b.x); }
frac operator+=(frac &a, frac b) { return a = a + b; }
frac operator-=(frac &a, frac b) { return a = a - b; }
frac operator*=(frac &a, frac b) { return a = a * b; }
frac operator/=(frac &a, frac b) { return a = a / b; }
bool operator<(frac a, frac b) { return a.x * b.y < b.x * a.y; }
bool operator>(frac a, frac b) { return a.x * b.y > b.x * a.y; }
bool operator<=(frac a, frac b) { return !(a > b); }
bool operator>=(frac a, frac b) { return !(a < b); }
bool operator==(frac a, frac b) { return a.x == b.x && a.y == b.y; }
bool operator!=(frac a, frac b) { return !(a == b); }

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<long long> dp(n + 1, -1e18);
	vector<long long> way(n + 1);
	dp[0] = 0;
	way[0] = 1;
	for (int i = 0; i < n; i++) {
		long long v;
		cin >> v;
		for (int j = n - 1; j >= 0; j--) {
			if (dp[j + 1] < dp[j] + v) {
				dp[j + 1] = dp[j] + v;
				way[j + 1] = way[j];
			} else if (dp[j + 1] == dp[j] + v) {
				way[j + 1] += way[j];
			}
		}
	}
	frac mx(0, 1);
	for (int i = a; i <= b; i++) {
		mx = max(mx, frac(dp[i], i));
	}
	printf("%.8f\n", (double)mx.x / mx.y);
	long long ans = 0;
	for (int i = a; i <= b; i++) {
		if (mx == frac(dp[i], i)) {
			ans += way[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string s;
  cin >> s;
  rep(i,0,s.size()){
    if(i % 2 == 0)
      cout << s[i];
  }
  cout << endl;
  ret 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <iostream>
#define ll long long
using namespace std;
char s[100005];
ll ans = 0;
int pos;

int main() {
    cin >> s;
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
        if(s[i] != '0') {
            pos = i;
            break;
        }
    }
    strcpy(s, s + pos);
    int k = atoi(s);
    if(k < 10) {
        printf("%d\n", k);
        return 0;
    }
    if(k >= 10 && k < 100) {
        puts("9");
        return 0;
    }
    if(k >= 100 && k < 1000) {
        printf("%d\n", 9 + (k - 99));
        return 0;
    }
    if(k >= 1000 && k < 10000) {
        puts("909");
        return 0;
    }
    if(k >= 10000 && k < 100000) {
        printf("%d\n", 909 + (k - 9999));
        return 0;
    }
    if(k == 100000)
        puts("90909");
    return 0;
}

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

int main()
{
  long double l;
  cin >> l;
  long double d=l/3;
  long double a =d*d*d;
  cout << fixed;
  cout << setprecision(12)<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	vector<P> small;
	vector<P> midium;
	vector<P> big;
	{
		small.pb(mp(0, -1));
		small.pb(mp(0, 1));
		small.pb(mp(0, 0));
		small.pb(mp(1, 0));
		small.pb(mp(-1, 0));
	}
	{
		midium.pb(mp(-1, -1));
		midium.pb(mp(0, -1));
		midium.pb(mp(1, -1));
		midium.pb(mp(-1, 0));
		midium.pb(mp(0, 0));
		midium.pb(mp(1, 0));
		midium.pb(mp(-1, 1));
		midium.pb(mp(0, 1));
		midium.pb(mp(1, 1));
	}
	{
		big.pb(mp(-2, 0));
		big.pb(mp(-1, -1));
		big.pb(mp(-1, 0));
		big.pb(mp(-1, 1));
		big.pb(mp(0, -2));
		big.pb(mp(0, -1));
		big.pb(mp(0, 0));
		big.pb(mp(0, 1));
		big.pb(mp(0, 2));
		big.pb(mp(1, -1));
		big.pb(mp(1, 0));
		big.pb(mp(1, 1));
		big.pb(mp(2, 0));
	}
	int field[10][10];
	memset(field, 0, sizeof field);
	for(int x, y, size; scanf(" %d,%d,%d", &x, &y, &size) != EOF;) {
		vector<P> drop;
		if(size == 1) drop = small;
		else if(size == 2) drop = midium;
		else drop = big;
		for(int i = 0, n = drop.size(); i < n; i++) {
			int nx = x + drop[i].first;
			int ny = y + drop[i].second;
			if(0 <= nx && nx < 10 && 0 <= ny && ny < 10) {
				field[nx][ny]++;
			}
		}
	}
#if 0
	for(int i = 0; i < 10; i++) {
		for(int j = 0; j < 10; j++) {
			printf("%d", field[j][i]);
		}
		puts("");
	}
#endif
	int white = 0;
	int most = 0;
	rep(l, 10) {
		white += count(field[l], field[l] + 10, 0);
		most = max(most, *max_element(field[l], field[l] + 10));
	}
	printf("%d\n%d\n", white, most);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl

int main() {
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
long double d[310][310][310];
int cnt1, cnt2, cnt3;

long double f(int a, int b, int c) {
	if (d[a][b][c] != INF)return d[a][b][c];
	long double res = 0;
	if (a)res += f(a - 1, b, c)*a;
	if (b)res += f(a + 1, b - 1, c)*b;
	if (c)res += f(a, b + 1, c - 1)*c;
	res += n;
	res *= 1.0 / (a + b + c);
	d[a][b][c] = res;
	return res;
}

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a == 1)cnt1++;
		else if (a == 2)cnt2++;
		else cnt3++;
	}
	for (int i = 0; i <= n; i++)for (int j = 0; j <= n; j++)for (int k = 0; k <= n; k++)d[i][j][k] = INF;
	d[0][0][0] = 0;
	printf("%.15Lf", f(cnt1, cnt2, cnt3));
}

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

const int N = 110000;

char str[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	cin >> str;
	int len = strlen(str);
	
	vector<char> buf;
	vector<int> pos;
	for (int i = 0; i < len; i++) if (str[i] != 'x') buf.push_back(str[i]), pos.push_back(i);
	for (int i = 0; i < buf.size(); i++) if (buf[i] != buf[buf.size() - 1 - i]) {
		cout << "-1\n";
		return 0;
	}
	if (buf.size() == 0) {
		cout << "0\n";
		return 0;
	}
	int r = pos[buf.size() / 2];
	int l = pos[buf.size() - 1 - buf.size() / 2];
	int ans = 0;
	while (l >= 0 && r < len) {
		if (str[l] == str[r]) l--, r++;
		else {
			if (str[l] == 'x') ans++, l--;
			else ans++, r++;
		}
	}
	ans += max(l + 1, len - r);
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 3916
#C
import sys
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
sc.sort(key=lambda x: x[0])
ans = [-1] * n
for i in range(m):
    #すでに値が入っているAND値が同じではない
    if ans[sc[i][0]-1] != -1 and ans[sc[i][0]-1]!=sc[i][1]:
        print(-1)
        sys.exit() 
    ans[sc[i][0] - 1] = sc[i][1]
#1桁目が-1未定義 -> n=2以上は最小値が1ダメ
if ans[0] == -1 and n >= 2:
    ans[0] = 1
#1桁目が0　　　　-> n=2以上は定義できない。
if ans[0] == 0 and n>=2:
    print(-1)
    sys.exit()
for i in ans:
    if i == -1:
        print(0, end="")
    else:
        print(i,end="")

Measured memory_bytes: 9180
#include <iostream>
#include <string>

int main() {
    int sx,sy,tx,ty;
    std::cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;

    std::string str(dy, 'U');
    str += std::string(dx, 'R');
    str += std::string(dy, 'D');
    str += std::string(dx + 1, 'L');
    str += std::string(dy + 1, 'U');
    str += std::string(dx + 1, 'R');
    str += "DR";
    str += std::string(dy + 1, 'D');
    str += std::string(dx + 1, 'L');
    str += 'U';
    std::cout << str << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    long long a[N], b[N], c[M], d[M];
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < M; i++){
        cin >> c[i] >> d[i];
    }
    for(int i = 0; i < N; i++){
        long long mindist = INFINITY;
        int index = -1;
        for(int j = 0; j < M; j++){
            long long tmpdist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(mindist > tmpdist){
                index = j;
                mindist = tmpdist;
            }
        }
        cout << index+1 << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

signed main()
{
  int N, M;
  cin >> N >> M;

  vector<int> n(N, 1);
  vector<bool> r(N, false);
  r.at(0) = true;
  for (int i = 0; i < M; i++)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    n.at(x)--, n.at(y)++;
    if (r.at(x))
      r.at(y) = true;
    if (!n.at(x))
      r.at(x) = false;
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (n.at(i) && r.at(i)) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024