akhauriyash/Code-Regression huggingface dataset:
N_str = input()

M = len(N_str)

result = 0

if M % 2 == 1:
    result += int(N_str) - (10**(M-1) - 1)
    M -= 1
    
for i in range(0, M, 2):
    result += 9 * 10**i

print(result)

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i =0; i<n; ++i){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  
  int ans = 0;
  
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < i; ++j){
      for(int k = 0; k < j; ++k){
        if(vec[k] != vec[j] and vec[i] != vec[j] 
           and vec[k] + vec[j] > vec[i]){
           ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
Xmax = 10**10
N, D, A = inpl()
XH = [inpl() for _ in range(N)]
XH.sort()
XH.append([Xmax,0])
ans = 0
d = 0
i = j = 0
R = []
while True:
    if j >= len(R) or XH[i][0] <= R[j][0]:
        x, h = XH[i]
        i += 1
        if x >= Xmax:
            break
        h -= d
        if h <= 0:
            continue
        else:
            k = (h-1)//A + 1
            R.append((x+2*D, k*A))
            d += k*A
            ans += k
    else:
        x, h = R[j]
        j += 1
        d -= h
print(ans)

Measured memory_bytes: 87308
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    double a, b;
    cin >> a >> b;
    if(a > b) cout << "GREATER" << endl;
    else if(b > a) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
int main() {
	string s;
	int a, b, c, d;
	cin >>s;
	bool f1 = 0, f2 = 0, f3 = 0, f4 = 0, f5 = 0, f6 = 0, f7 = 0, f8 = 0;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
		if (a + b + c + d == 7) { f1 = 1; }
		else if (a + b + c - d == 7) { f2 = 1; }
		else if (a + b - c + d == 7) { f3 = 1; }
		else if (a - b + c + d == 7) { f4 = 1; }
		else if (a + b - c - d == 7) { f5 = 1; }
		else if (a - b + c - d == 7) { f6 = 1; }
		else if (a - b - c + d == 7) { f7 = 1; }
		else if (a - b - c - d == 7) { f8 = 1; }

		if (f1 == 1) { cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl; }
		if (f2 == 1) { cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl; }
		if (f3 == 1) { cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl; }
		if (f4 == 1) { cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl; }
		if (f5 == 1) { cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl; }
		if (f6 == 1) { cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl; }
		if (f7 == 1) { cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl; }
		if (f8 == 1) { cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl; }


	return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        int[] arr = new int[n];
        int res = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
            while (arr[i] % 2 == 0) {
                arr[i] >>= 1;
                res++;
            }
        }
        in.nextLine();
        System.out.println(res);
    }
}


Measured memory_bytes: 48204
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  string str;
  cin >> str;
  long long ret = atoll(str.c_str());
  int n=str.size()-1;
  for(int i=0;i<n;i++){
      vector<int> dat;
      for(int j=0;j<i;j++){
          dat.push_back(0);
      }
      for(int j=i;j<n;j++){
          dat.push_back(1);
      }
      do{
          int head=0;
          //cout <<"nextperm"<<endl;
          for(unsigned int i=0; i<dat.size(); ++i){
              if(dat[i]==1){
                  //cout <<atoi(str.substr(head,i+1-head).c_str())<<endl;
                  ret += atoll(str.substr(head,i+1-head).c_str());
                  head=i+1;
                  //cout <<ret<<endl;
              }
          }
         // cout << str.substr(head);
          ret += atoll(str.substr(head).c_str());
         // cout <<endl;
         // cout <<ret<<endl;
      }while(next_permutation(dat.begin(), dat.end()));
  }
  cout << ret<<endl;

}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if (a != 1 && b != 1)
    {
        cout<<1;
    }
    if (a != 2 && b != 2)
    {
        cout<<2;
    }
    if (a != 3 && b != 3)
    {
        cout<<3;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
	int N, H[1000], T, A, i, tem = 1000000000, ans;

	scanf("%d", &N);
	scanf("%d %d", &T, &A);
	for (i = 0; i < N; i++) {
		scanf("%d", &H[i]);
		if (tem > abs(A * 1000 - (T * 1000 - H[i] * 6))) {
			tem = abs(A * 1000 - (T * 1000 - H[i] * 6));
			ans = i + 1;
		}
	}
	
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 19, M = 53, inf = 1e9;
map<pair<vector<pii>, int>, int> mp;

int solve(vector<pii>& a, int mx) {
    if (a.size() == 1) {
        if (a[0].F <= mx) return 0;
        else return inf;
    }
    if (mp.count({a, mx})) {
        return mp[{a, mx}];
    }
    int n = a.size(), ans = inf;
    vector<pii> b;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            b.pb({a[j].S, a[j].F});
        }
        if (a[i].F <= mx && (n - 1 - i)%2 == 0) {
            ans = min(ans, solve(b, a[i].F) + (n - 1 - i));
        }
        if (a[i].S <= mx && (n - 1 - i)%2 == 1) {
            ans = min(ans, solve(b, a[i].S) + (n - 1 - i));
        }
        for (int j=i+1; j<n; j++) {
            b.pop_back();
        }
        b.pb(a[i]);
    }
    return mp[{a, mx}] = ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    vector<pii> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i].F;
    }
    for (int i=0; i<n; i++) {
        cin >> a[i].S;
    }
    int ans = solve(a, 60);
    if (ans == inf) cout << "-1\n";
    else cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 58624
/**
*    author:  souzai32
*    created: 13.08.2020 13:26:20
**/

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

int main() {

    int n,x,y;
    cin >> n >> x >> y;
    vector<int> d(n);
    int dist;

    for(int i=1; i<n; i++){
        for(int j=n; j>i; j--){
            dist=min(j-i,abs(x-i)+1+abs(y-j));
            d.at(dist)++;
        }
    }

    for(int i=1; i<n; i++) cout << d.at(i) << endl; 

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define reverse(s) reverse(s.begin(), s.end());
#define p pair<int,int>
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	rep(i, n) {
		cin >> h[i];
		h[i] *= 6;
	}
	int x = (t-a) * 1000 ;
	int mini = 0;
	int minh = INF;
	rep(i, n) {
		if (abs(x - h[i]) < minh) {
			mini = i;
			minh = abs(x - h[i]);
		}
	}
	cout << 1 + mini << endl;

}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn], b[maxn], c[maxn], d[maxn];
int n, m, q;

vector<int> v;
int solve(int pos, int last) {
	if (pos == n) {
		int ans = 0;
		for (int i = 0; i < q; ++i) {
			ans += d[i] * (v[b[i]-1] - v[a[i]-1] == c[i]); 	
		}
		return ans;
	}
	int ans = 0;
	for (int i = last; i <= m; ++i) {
		v.push_back(i);
		ans = max(ans, solve(pos+1, i));	
		v.pop_back();
	}
	return ans;
}

int main() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; ++i) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	cout << solve(0, 1) << endl;
	return 0;
}

Measured memory_bytes: 3600
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,d:i64,
      mut  xy:[(i64,i64);n],
    }
    let mut ans = 0;
    for &(x, y) in xy.iter() {
        if x * x + y * y <= d * d {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 7880
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			StringBuffer[] ice = new StringBuffer[10];
		
			int n = sc.nextInt();
			if(n==0) break;
		
			for(int i=0; i<10; i++)
				ice[i] = new StringBuffer("-");
			
			for(int i=0; i<n; i++){
				int a = sc.nextInt();
				
				if(ice[a].toString().equals("-")){
					ice[a].delete(0,1);
					ice[a].append("*");
				}
				else{
					ice[a].append("*");
				}
			}
		
			for(int i=0; i<10; i++)
				System.out.println(ice[i]);
		}
		
	
	}
}

Measured memory_bytes: 61408
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, 100) {
        rep(j, 0, 100) {
            if (4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;
int n;
const int N = 4e5;
int a[N], b[N];
long long ans;
multiset<pair<int, int> > L, R;
void go(long long &cur, int i) {
    L.erase(L.find(make_pair(a[i], i)));
    R.erase(R.find(make_pair(b[i], i)));
    if (cur < a[i]) {
        ans += a[i] - cur;
        cur = a[i];
    }
    else
    if (cur > b[i]) {
        ans += cur - b[i];
        cur = b[i];
    }
}
long long solveL() {
    for (int i = 1; i <= n; i++) L.insert(make_pair(a[i], i));
    for (int i = 1; i <= n; i++) R.insert(make_pair(b[i], i));
    ans = 0;
    long long cur = 0;
    for (int i = 1; i <= n; i++) {
        auto it1 = L.end(); it1--;
        auto it2 = R.begin();
        int x = it1 -> first; int y = it2 -> first;
        if (it1 -> first > cur && it2 -> first < cur) {
            go(cur, it1 -> second);
        }
        else
        if (it1 -> first <= cur && it2 -> first >= cur) break;
        else
        if (it1 -> first > cur) go(cur, it1 -> second);
        else go(cur, it2 -> second);
    }
    ans += abs(cur);
    return ans;
}
long long solveR() {
    for (int i = 1; i <= n; i++) L.insert(make_pair(a[i], i));
    for (int i = 1; i <= n; i++) R.insert(make_pair(b[i], i));
    ans = 0;
    long long cur = 0;
    for (int i = 1; i <= n; i++) {
        auto it1 = L.end(); it1--;
        auto it2 = R.begin();
        int x = it1 -> first; int y = it2 -> first;
        if (it1 -> first > cur && it2 -> first < cur) {
            go(cur, it2 -> second);
        }
        else
        if (it1 -> first <= cur && it2 -> first >= cur) break;
        else
        if (it1 -> first > cur) go(cur, it1 -> second);
        else go(cur, it2 -> second);
    }
    ans += abs(cur);
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    cout << max(solveL(), solveR()) << "\n";
    return 0;
}


Measured memory_bytes: 15104
N, M = map(int, input().split())

list_ac = [0 for i in range(N)]
list_pen = [0 for i in range(N)]
list_count = [0 for i in range(N)]

for i in range(M):
  pS = input().split()
  p = int(pS[0])-1
  S = pS[1]
  if S == "AC":
    list_pen[p] += list_count[p] * (1 - list_ac[p])
    list_ac[p] = 1
  else:
    list_count[p] += 1

print(str(sum(list_ac)) + " " + str(sum(list_pen)))

Measured memory_bytes: 5528
#include <iostream>
using namespace std;
int main(void){
    int n,d[100002][3];
    cin>>n;
    d[0][0]=d[0][1]=d[0][2]=0;
    for(int i=1;i<=n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        d[i][0]=max(d[i-1][1],d[i-1][2])+a;
        d[i][1]=max(d[i-1][0],d[i-1][2])+b;
        d[i][2]=max(d[i-1][0],d[i-1][1])+c;
    }
    
    cout<<max(max(d[n][0],d[n][1]),d[n][2])<<endl;
}


Measured memory_bytes: 1408
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
ll a[100000];

int test(ll x)
{
    vector<ll> m(N);
    ll d = x;
    REP(i, N){
        m[i%N] += d;
        m[(i+1)%N] += a[i%N] - d;
        d = a[i%N] - d;
    }
    //cout << "[";
    //REP(i, N-1) cout << m[i] << " ";
    //cout << m[N-1] << "]" << endl;

    if(m[0] + m[N-1] == 2*a[N-1]){
        //cout << x << " " << 0 << endl;
        return 0;
    }
    else if(m[0] + m[N-1] > 2*a[N-1]){
        //cout << x << " " << 1 << endl;
        return 1;
    }
    else{
        //cout << x << " " << -1 << endl;
        return -1;
    }
}

void createAns(vector<ll> &v, ll x)
{
    ll d = x;
    REP(i, N){
        v[i%N] += d;
        v[(i+1)%N] += a[i%N] - d;
        d = a[i%N] - d;
    }
}


void solve()
{
    ll lb = -1, ub = a[0];
    while(ub - lb > 1){
        ll mid = (lb + ub) / 2;
        int ret = test(mid);
        if(ret == 0){
            ub = mid;
            break;
        }else if(ret > 0){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    //cout << ub << endl;
    vector<ll> ans(N);
    createAns(ans, ub);
    REP(i, N-1) cout << ans[i] << " ";
    cout << ans[N-1] << endl;

}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 2928
#include <stdio.h>
int main()
{
    int n, a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (i != 0)
        {
            printf("%d ", a[i]);
        }
        else
        {
            printf("%d\n", a[0]);
        }
    }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,W; cin>>n>>W;
	int V=0;
	vector<int>w(n),v(n);
	for(int i=0;i<n;++i){
		cin>>w.at(i)>>v.at(i);
		V+=v.at(i);
	}
	vector<vector<int64_t>>dp(2,vector<int64_t>(V+1,1e9));
	dp.front().front()=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<=V;++j){
			if(j<v.at(i))dp.at((i+1)&1).at(j)=dp.at(i&1).at(j);
			else dp.at((i+1)&1).at(j)=min(dp.at(i&1).at(j),dp.at(i&1).at(j-v.at(i))+w.at(i));
		}
	}
	int ans=0;
	for(int i=V;i>=0;--i){
		if(dp.at(n&1).at(i)<=W){
			ans=i;
			break;
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 5572
#include<bits/stdc++.h>//stop myself from getting UKE
using namespace std;
const int N=2e5+10;
int siz,he[N],e,edg,col[N];
bool vis[N],flag;
struct sa{
	int ne,va,to;
} a[N];
long long ans=0,cot[3];
void add(int u,int v,int w){
	a[++e].to=v;
	a[e].va=w;
	a[e].ne=he[u];
	he[u]=e;
}
void dfs(int k){
	cot[col[k]]++;
	vis[k]=1;
	
	for(int i=he[k];i;i=a[i].ne){
		edg+=(a[i].va==1);
		int v=a[i].to;
		int rec=(3+col[k]+a[i].va)%3;
		if(!vis[v]){
		    siz++;
		    col[v]=rec;
		    dfs(v);
	    }
	    else if(col[v]!=rec) flag=0;
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v,1);
		add(v,u,-1);
	}
	for(int i=1;i<=n;i++) if(!vis[i]){
		edg=cot[1]=cot[0]=cot[2]=0;
		siz=flag=1;
		dfs(i);
		if(!flag) ans+=(long long)siz*siz;
		else if(cot[0]&&cot[1]&&cot[2]) ans+=(long long) cot[0]*cot[1]+(long long) cot[0]*cot[2]+(long long) cot[1]*cot[2]; 
		else ans+=edg;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7424
#include <iostream>
#include <cstring>
using namespace std;
char S[55];
int N;
void Read()
{
    cin.getline(S + 1, 55);
    N = strlen(S + 1);
    for(int i = 1;i < N - 7; i++)
        cout << S[i];
    cout << "\n";
}
int main()
{
    Read();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> x(N), y(N), sum(N), diff(N);
	for (int i=0; i<N; i++)
		cin>>x[i]>>y[i], sum[i]=x[i]+y[i], diff[i]=x[i]-y[i];
	int a=*max_element(sum.begin(),sum.end())-*min_element(sum.begin(),sum.end());
	int b=*max_element(diff.begin(),diff.end())-*min_element(diff.begin(),diff.end());
	cout<<max(a,b)<<"\n";
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 10399;
const ll MAXN = (ll) 1e3 + 10;
const ll INF = (ll) LONG_LONG_MAX / 100;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

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

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

int main(){
	/*
	ll n, k;
	cin >> n>> k;
	cout << n -k+1;*/
	ll n;
	cin >> n;
	str s;
	ll a = 0, b = 0, ans = 0, c = 0;;
	for(int i = 0; i < n;i++){
		cin >> s;
		ll m = s.size();
		for(int j = 0; j + 1 < m;j++){
			if((s[j] == 'A') and (s[j + 1] == 'B')) ans ++;
		}
		if(s[0] == 'B') b ++;
		if(s[m - 1] == 'A') a ++;
		if((s[0] == 'B') && (s[m - 1] == 'A')) c ++;
	}
	if(a == b and c == a) return cout << ans + max(0ll, a - 1ll), 0;
	
	else cout << ans + min(n - 1ll, min(a, b));
	return 0;
}


/*
fuck hashal
*/



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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  int a = A / K;
  int b = B / K;
  if (K*a == A){
   cout << "OK" << endl;
  }else if (a != b){
   cout << "OK" << endl;
  }else{
   cout << "NG" << endl;
  }
}

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

int main() {

  int N;
  cin >> N;

  vector<int> a(N);
  for(int i = 0;i < N;i++) {
    cin >> a.at(i);
  }

  a.push_back(10000);

  int sum = 0,num = 1;
  for(int i = 0;i < N;i++) {
    if(a.at(i) == a.at(i+1)) num++;
    else {
      sum += num / 2;
      num = 1;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int N = 1000000;
int main(){
	int n;
	vector<bool> v(N,true);
	v[0] = false;
	v[1] = false;
	for (int i=2; i<N; ++i){
		if (v[i] == true){
			for (int j=2*i; j<N; j+=i){
				v[j] = false;
			}
		}
	}
	vector<int> cnt(N);
	for (int i=2; i<N; ++i){
		if (v[i]) cnt[i] = cnt[i-1]+1;
	   else cnt[i] = cnt[i-1];
	}
	while (cin >> n){
		cout << cnt[n] << '\n';
	}
	return 0;
}


Measured memory_bytes: 6608
#include "bits/stdc++.h"

using namespace std;

int main() {
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;++i){
        int d;
        scanf("%d",&d);
        mp[d]++;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;++i){
        int t;
        scanf("%d",&t);
        mp[t]--;
        if(mp[t]<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}



Measured memory_bytes: 9600
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-27 19:43:37
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

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

  int64 ans = 0;
  vector<int64> sum(n + 1, 0LL);
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + a[i]; 
  }
  map<int64, int> mp;

  for (int i = 0; i < n + 1; ++i) {
    ans += mp[sum[i]];
    ++mp[sum[i]];
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") {
		cout << "No";
	} else {
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
S = []
for i in range(n):
    s = collections.Counter(input())
    S.append(s)
ans = ''
for key in S[0].keys():
    cnt = S[0][key]
    for i in range(1,n):
        cnt = min(cnt,S[i][key])
    for i in range(cnt):
        ans += key
ans = sorted(ans)
print(''.join(ans))

Measured memory_bytes: 9348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()


int main(){
  string N;cin>>N;
  int K;cin>>K;
  int dp[110][2][4];
  rep(i,110)rep(j,2)rep(k,K+1)dp[i][j][k]=0;
  dp[0][0][0]=1;
  rep(i,N.size()){
    rep(smaller,2){
      rep(condition,4){
        for(int j=0;j<=(smaller ? 9 : (N[i]-'0'));++j){
          if((condition + !!j) >= 4) continue;
          dp[i + 1][smaller || j < (N[i]-'0')][condition + !!j] += dp[i][smaller][condition];
          //cout << "dp" << dp[i][smaller][condition] << endl;
        }
      }
    }
  }
  //cout << "N " << N.size() << K << endl;
  //cout << " " << dp[N.size()][0][K] << " " << dp[N.size()][1][K] << endl;
  cout << dp[N.size()][0][K] + dp[N.size()][1][K] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define p5 100005
#define ll long long
using namespace std;
ll ar[p5];
int main()
{
    int n,k,i,j,l;
    cin>>n>>k;
    int w[n+1],v[n+1];
    for(i=1; i<=n; i++)
    {
        cin>>w[i]>>v[i];
    }
    for(i=1; i<=n*1000; i++)
    {
        ar[i]=p5*p5;
    }
    for(i=1; i<=n; i++)
    {
        for(j=n*1000; j>=v[i]; j--)
        {
            ar[j]=min(ar[j],ar[j-v[i]]+w[i]);

        }
    }
    for(i=n*1000; i>=0; i--)
    {
        if(ar[i]<=k)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}
/*
3 8
3 3
4 5
5 6
*/


Measured memory_bytes: 1152
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#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 <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    int N,M;cin >> N >> M;
    int ans = 0;
    for(int i = 1;i<=N;i++){
        for(int j = 1;j<=M;j++){
            int month = i;
            int ten = j/10;
            int one = j%10;
            if(ten >= 2 && one >= 2 && one*ten == month) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int a, b;
	cin >> a >> b;
	string ans;
	if (a <0) {
		if (b < 0) {
			if ((a + b + 1) % 2 == 0)ans = "Positive";
			else ans = "Negative";
		}
		else ans = "Zero";
	}
	if (a == 0)ans = "Zero";
	if (a > 0)ans = "Positive";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
function puts($str = ""){
    echo $str, "\n";
}

$input = trim(fgets(STDIN));
$n = intval($input);
$input = trim(fgets(STDIN));
$a_list = preg_split('/\s/', $input);
$a_list = array_map(function($a){
    return intval($a);
}, $a_list);
sort($a_list);
$min = $a_list[0];
while(count($a_list) > 1){
    $result = array($a_list[0]);
    foreach(array_slice($a_list, 1) as $a){
        if($a % $a_list[0] > 0){
            $result[] = $a % $a_list[0];
        }
    }
    $a_list = array_values($result);
    sort($a_list);
    $min = $a_list[0];
}

puts($min);


Measured memory_bytes: 45992
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int64_t INF = 1LL << 60;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int64_t N, M, R;
    cin >> N >> M >> R;
    vector<int64_t> r(R), A(M), B(M), C(M);
    rep(i, 0, R) cin >> r.at(i);
    sort(all(r));
    rep(i, 0, M) cin >> A.at(i) >> B.at(i) >> C.at(i);
    vector<vector<int64_t>> d(N, vector<int64_t>(N, INF));
    rep(i, 0, N){
        d.at(i).at(i) = 0;
    }
    rep(i, 0, M){
        d.at(A.at(i) - 1).at(B.at(i) - 1) = C.at(i);
        d.at(B.at(i) - 1).at(A.at(i) - 1) = C.at(i);
    }
    rep(k, 0, N){
        rep(i, 0, N){
            rep(j, 0, N){
                d.at(i).at(j) = min(d.at(i).at(j), + d.at(i).at(k) + d.at(k).at(j));
            }
        }
    }
    int64_t ans_f = INF;
    do{
        int64_t ans = 0;
        rep(i, 0, R - 1){
            ans += d.at(r.at(i + 1) - 1).at(r.at(i) - 1);
        }
        ans_f = min(ans_f, ans);
    }
    while(next_permutation(all(r)));
    
    cout << ans_f << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (long long i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
 
int n,m;
int mas[1000],x[1000];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    while(true) {
	cin>>n>>m;
	if(n==0&&m==0) break;
	REP(i,1000) mas[i]=x[i]=0;
	REP(i,n) {
		cin>>mas[i];
	}
	int pos=0;
	REP(i,m) {
		cin>>x[i];
	}
	REP(i,m) {
		pos+=x[i]+mas[pos+x[i]];
		if(pos>=n-1) {
			cout<<i+1<<endl;
    		break;
		}
	}
    }
 
	return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    long long A, B, C;
    cin >> A >> B >> C;
    if(A%2==1 && B%2==1 && C%2==1) cout << min({A*B,B*C,C*A}) << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	static Scanner s = new Scanner(System.in);
	private static final int MOD =1_000_000_007;

	public static void main(String[] args) {
		LikePrimeIterator lpi = new LikePrimeIterator();
		ArrayDeque<Long> in = new ArrayDeque<>();
		long result=1;
		{
			long b=1;
			for(int i=s.nextInt();i>1;i--) {
				if(b<1_000_000_000_000L) {
					b*=i;
				}else {
					in.add(b);
					b=i;
				}
			}
			in.add(b);
		}
		{
			long LPI,list,count,size;
			while(!in.isEmpty()) {
				count=1;
				LPI=lpi.next();
				size=in.size();
				for(int i=0;i<size;i++){
					list=in.poll();
					while(list%LPI==0) {
						list/=LPI;
						count++;
					}
					if(list>1)
						in.add(list);
				}
				result*=count;
				result%=MOD;
			}
		}
		System.out.println(result);
	}
}
class LikePrimeIterator implements Iterator<Long>{
	long curValue = 0;
	long nextValue = 2;
	public LikePrimeIterator() {
	}
	@Override
	public boolean hasNext() {
		return nextValue>0;
	}
	@Override
	public Long next() {
		if(hasNext()) {
			long b = (curValue=nextValue)%6;

			if(b==5)
				nextValue+=2;
			else if (b==1)
				nextValue+=4;
			else if(b==2)
				nextValue=3;
			else
				nextValue=5;

			return curValue;

		}else {
			throw new NoSuchElementException();
		}
	}
	public long get() {
		return curValue;
	}
	public void reset() {
		nextValue=2;
	}
}


Measured memory_bytes: 10448
n, a = list(map(int, input().split()))
xs = list(map(int, input().split()))

na = n*a

DP = [[0]*(na+1) for i in range(n+1)]
DP[0][0] = 1

for _ in range(n):
    x = xs[_]
    next = [[0]*(na+1) for i in range(n+1)]
    for i in range(_+1):
        for j in range(na+1):
            # xを使わないとき
            next[i][j] += DP[i][j]
            if j+x <= na:
                next[i+1][j+x] += DP[i][j]
    DP = next

# i枚使ったとき合計がi*aである場合の数
ans = 0
for i in range(1,n+1):
    ans += DP[i][i*a]
print(ans)

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

using namespace std;

int main()
{
    long long k,i;
    cin>>k;
    int x=7%k;
    for(i=1;i<=k;i++){
        if(x==0){
            cout<<i;
            return 0;
        }
        x=(x*10+7)%k;
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3644
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e3 + 10;
int solve(int n, int m)
{
	int cnt = 1;
	while ((n & 1) == (m & 1))
	{
		cnt++;
		n >>= 1;
		m >>= 1;
	}
	return cnt;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			printf("%d%c", solve(i - 1, j - 1), " \n"[j == n]);
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 1 << 30;
  
  vector<int> w,e;
  w.resize(n); e.resize(n);
  
  w[0] = 0;
  e[n-1] = 0;
  
  for(int i = 1; i < n; i++){
    if(s[i-1] == 'W') w[i] = w[i-1] + 1;
    else w[i] = w[i-1];
  }
  for(int i = n-2; i >= 0; i--){
    if(s[i+1] == 'E') e[i] = e[i+1] + 1;
    else e[i] = e[i+1];
  }
  
  rep(i,n) chmin(ans, w[i]+e[i]);
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define CLR(a) memset((a), 0, sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

//using LL = long long;
using namespace std;

const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n, A[100], mini, count = 0;
    cin >> n;
    vector<int> v;
    int temp;
    for (; cin >> temp;)
    {
        v.push_back(temp);
    }

    for (int i = 0; i < n - 1; i++){
        mini = i;
        for (int j = i + 1; j < n; j++){
            if (v[j] < v[mini])
                mini = j;
        }

        if (i != mini){
            count++;
            swap(v[i], v[mini]);
        }
    }

    for (int i = 0; i < n; i++){
        if (i) cout << ' ';
        cout << v[i];
    }
    cout << endl << count << endl;

    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	
	int n;
	cin>>n;
	int ac=0,tle=0,wa=0,re=0;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s=="AC")
			ac++;
		else if(s=="WA")
			wa++;
		else if(s=="TLE")
			tle++;
		else
			re++;
	}

	cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<re<<endl;	
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll t,i,j,n,d,ans=0;
	cin>>n;
	string s;
	cin>>s;
	ll w=0,r=0;
	for(auto a:s)
	{
		w += a=='W';
		r += a=='R';
	}
	for(i=0;i<r;i++)
	{
		if(s[i]!='R') ans++;
	}
	cout<<min(ans,w);
	return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    rep(i,n) cin >> a[i];

    ll hmin = a[0];
    rep1(i,n) {
        if (a[i] < hmin) {
            ans += hmin - a[i];
        }
        if (a[i] > hmin) {
            hmin = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4752
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

module String =
    /// Converts a string into a list of characters.
    let explode (s:string) =
        [for c in s -> c]

    /// Converts a list of characters into a string.
    let implode (xs:char list) =
        let sb = System.Text.StringBuilder(xs.Length)
        xs |> List.iter (sb.Append >> ignore)
        sb.ToString()

let cnt = Array.create 26 0
Console.ReadLine()
|> String.explode
|> List.map (fun c -> (int c) - (int 'a'))
|> List.iter (fun cc -> cnt.[cc] <- cnt.[cc] + 1)

cnt
|> Array.forall (fun c -> c % 2 = 0 )
|> (fun c -> if c then "Yes" else "No")
|> Console.WriteLine


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

int main() {
    int N;
    cin >> N;
    int A = N/1000, B = (N/100)%10, C = (N/10)%10, D = N%10;

    if (A + B + C + D == 7) printf("%d+%d+%d+%d=7\n", A, B, C, D);
    else if (A + B + C - D == 7) printf("%d+%d+%d-%d=7\n", A, B, C, D);
    else if (A + B - C + D == 7) printf("%d+%d-%d+%d=7\n", A, B, C, D);
    else if (A - B + C + D == 7) printf("%d-%d+%d+%d=7\n", A, B, C, D);
    else if (A + B - C - D == 7) printf("%d+%d-%d-%d=7\n", A, B, C, D);
    else if (A - B - C + D == 7) printf("%d-%d-%d+%d=7\n", A, B, C, D);
    else if (A - B + C - D == 7) printf("%d-%d+%d-%d=7\n", A, B, C, D);
    else if (A - B - C - D == 7) printf("%d-%d-%d-%d=7\n", A, B, C, D);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define S 2010
using namespace std;
using ll = int64_t;
ll sum[510][510];
int main(){
    ll N, M, Q;
    cin >> N >> M >> Q;
    for(ll i = 0; i < M; i++){
        ll l, r;
        cin >> l >> r;
        sum[l][r]++;
    }
    for(ll r = 0; r < 510; r++) for(ll l = 1; l < 510; l++) sum[l][r] += sum[l - 1][r];
    for(ll i = 0; i < Q; i++){
        ll p, q;
        cin >> p >> q;
        ll ans = 0;
        for(ll r = p; r <= q; r++) ans += sum[r][r] - sum[p - 1][r];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int main(){
  
  int N, a[100];

  cin >> N;
  for(int i = 0; i < N; i++) 
    cin >> a[i];
  
  for(int i = 0; i < N; i++) {
    int j, v = a[i];
    for(j = i - 1; j >= 0 && a[j] > v; j--)
      a[j + 1] = a[j];
    a[j + 1] = v;
    
    for(int i = 0; i < N; i++)
      printf("%d%c", a[i], (i != N - 1 ? ' ' : '\n'));
  }
}

Measured memory_bytes: 1144
#include<stdio.h>
#include<stdlib.h>
int left(int i){
  return i*2;
}
int right(int i){
  return i*2+1;
}
void maxheapify(int A[],int i,int x){
  int l=left(i);
  int r=right(i);
  int key,largest;
  if(l<=x && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=x && A[r]>A[largest])largest=r;
  if(largest!=i){
    key=A[i];
    A[i]=A[largest];
    A[largest]=key;
    maxheapify(A,largest,x);
  }
}
void buildmaxheap(int A[],int x){
  for(int i=x;1<=i;i--){
    maxheapify(A,i,x);
  }
}
int main(){
  int *h;
  int i,j,n;
  scanf("%d",&n);
  h=malloc(n *sizeof(int));
  for(i=1;i<=n;i++){
    scanf("%d",&h[i]);
  }
  buildmaxheap(h,n);
  for(i=1;i<=n;i++){
    printf(" %d",h[i]);
  }
  printf("\n");
  free(h);
  return 0;
}



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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int x = 0, y = 0, z = 0;
    for(int i=0; i<n; i++){
        int p;
        cin >> p;
        if(p <= a) x++;
        else if(a < p && p <= b) y++;
        else z++;
    }
    cout << min({x, y, z}) << endl;
    return 0;
}

Measured memory_bytes: 256
import math, itertools
n = int(input())
def d(a, b):
  return math.sqrt(((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))
lst = []
for i in range(n):
  x, y = map(int, input().split())
  lst.append([x, y])
ans = 0
for v in itertools.permutations(lst, 2):
  ans += d(v[0], v[1])
print(ans/n)

Measured memory_bytes: 3064
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
s = set(a)
l = len(s)
c = Counter(a)
if l == 1:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")
elif l == 2:
    x, y = min(a), max(a)
    if x == 0 and c[0] == n / 3:
        print("Yes")
    else:
        print("No")
elif l == 3:
    x, y, z = s
    if x ^ y ^ z == 0 and c[x] == c[y] == c[z]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 20996
#include<cstdio>
#define maxn 10000005
#define tt 998244353
#define LL long long
using namespace std;
int n,ans,fac[maxn],inv[maxn];
inline int C(int n,int m){return (LL)fac[n]*inv[m]%tt*inv[n-m]%tt;}
inline int qsm(int a,int b){
	int s=1,w=a%tt;
	while (b){
		if (b&1) s=(LL)s*w%tt;
		w=(LL)w*w%tt;
		b>>=1;
	}
	return s;
}
int main(){
	scanf("%d",&n);
	fac[0]=1;for (int i=1;i<=n;i++) fac[i]=(LL)fac[i-1]*i%tt;
	inv[1]=1;for (int i=2;i<=n;i++) inv[i]=(LL)inv[tt%i]*(tt-tt/i)%tt;
	inv[0]=1;for (int i=1;i<=n;i++) inv[i]=(LL)inv[i-1]*inv[i]%tt;
	ans=qsm(3,n);
	for (int i=n/2+1;i<=n;i++) ans=(ans-(LL)2*C(n,i)*qsm(2,n-i)%tt)%tt;
	printf("%d\n",(ans+tt)%tt);
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

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

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	ll d = c-a-b;
	if(d>=2 && d*d> 4*a*b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256