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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
ll c[200005];
int d[200005];
ll ds, cs;
void solve() {
    cin >> n;
    rep(i, n) {
        cin >> d[i] >> c[i];
        cs += c[i]; ds += d[i] * c[i];
    }

    cout << cs - 1 + (ds - 1) / 9 << endn;
}

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


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

using namespace std;

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

  int k, s;
  cin >> k >> s;
  int res = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (i+j > s) continue;
      if (s-i-j <= k) {
        ++res;
      } else continue;
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int n;
  unsigned long long data[2];
  void set_data(int in){
    if ( in >= 64)in-=64,data[1]|=(1LL << in);
    else data[0]|=(1LL<<in);
  }
  bool operator<(const state & a)const{
    if(  n != a.n)return n<  a.n;
    rep(i,2)if (data[i] != a.data[i])return data[i] < a.data[i];
    return false;
  }
};


string tmp[128];
int group[13][2][128];
state data[13][2];
//q number of query
int solve(int n,int q,int depth,bool *used,int *in,map<state,int> & M){
  if (n == 1)return 0;
  int ret=q;
  rep(i,q){
    int cnt[2]={0};
    if ( used[i]==true)continue;
    data[depth+1][0].data[0]=data[depth+1][0].data[1]=0;
    data[depth+1][1].data[0]=data[depth+1][1].data[1]=0;
    rep(j,n){
      if ( tmp[in[j]][i] == '0')data[depth+1][0].set_data(in[j]),group[depth+1][0][cnt[0]++]=in[j];
      else data[depth+1][1].set_data(in[j]),group[depth+1][1][cnt[1]++]=in[j];
    }
    if ( cnt[0] == n || cnt[1]==n)continue;//all object has same features.
    data[depth+1][0].n=cnt[0];
    data[depth+1][1].n=cnt[1];
    int calc[2];
    used[i]=true;
    rep(j,2){
      if (M.find(data[depth+1][j])==M.end())calc[j]=M[data[depth+1][j]]=solve(cnt[j],q,depth+1,used,group[depth+1][j],M);
      else calc[j]=M[data[depth+1][j]];
    }
    ret=min(ret,1+max(calc[0],calc[1]));
    used[i]=false;
  }

  return ret;
}

main(){
  int m,n;
  while(cin>>m>>n && m){
    int in[n];
    bool used[n];
    map<state,int>M;
    rep(i,n)cin>>tmp[i],in[i]=i,used[i]=false;
    cout << solve(n,m,0,used,in,M)<<endl;
  }
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n;
void solve(){
	string ans = "";
	while(n){
		int cur = n % 26;
		if(!cur){
			ans += 'z';
			if(n == 26) break;
		}
		else ans += (cur - 1 +  'a');
		n -= 1;
		n /= 26;
	}
	reverse(all(ans));
	cout << ans << endl;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	solve();	
	return 0;
}
//do smt instead of nothing! never give up!


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

#define for_(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long lint;
template<typename T > void modMul(T& a, T b, T m) { a = (a*b)%m; }
template<typename T > void modAdd(T& a, T b, T m) { a = (a+b)%m; }

const lint MOD = (lint)1e9 + 7;

lint power(lint x, int k) {
	lint res = 1;
	while (k) {
		if (k & 1) modMul(res, x, MOD);
		modMul(x, x, MOD);
		k >>= 1;
	}
	return res;
}

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	
	int S = H+W+10;
	vector< lint > fact(S, 0);
	fact[0] = fact[1] = 1;
	for_(i,2,S) fact[i] = (fact[i-1] * i) % MOD;
	
	vector< lint > inv(S, 0);
	for_(i,0,S) inv[i] = power(fact[i], MOD-2);
	
	auto nCk = [&](int n, int k) {
		if (k == 0) return 1LL;
		lint res = fact[n];
		modMul(res, inv[n-k], MOD);
		modMul(res, inv[k], MOD);
		return res;
	};
	
	lint ans = 0;
	for_(i,B,W) {
		lint add = nCk(H-A-1+i, i);
		modMul(add, nCk(A-1+W-1-i, W-1-i), MOD);
		modAdd(ans, add, MOD);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>a>>b;
    if(a<b) cout<<0<<endl;
    else cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 3588
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));
//$v = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$N;$i++) {
  list($x[],$y[],$h[]) = explode(" ",trim(fgets(STDIN)));
}
$max = 100;

for($j=0;$j<=$max;$j++) {
  for($k=0;$k<=$max;$k++) {
    $needH = -1;
    for ($i=0;$i<$N;$i++) {
      if ($h[$i]>0) {
        $tmp = $h[$i] + abs($j-$y[$i]) + abs($k - $x[$i]);
        if ($needH == -1) {
          $needH = $tmp;
        }
        else {
          if ($needH != $tmp) {
            $needH = -2;
            break;
          }
        }
      }
    }
    if ($needH == -2) continue;
    for($i=0;$i<$N;$i++) {
      if ($h[$i]==0) {
        $dist = abs($j-$y[$i])+abs($k-$x[$i]);
        if ($needH > $dist) {
          $needH = -2;
          break;
        }
      }
    }
    if ($needH == -2) continue;
    printf("%d %d %d\n",$k,$j,$needH);
    exit;
  }
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N, A, B;
  cin>>N>>A>>B;
  if(A%2==B%2){
    cout << (B - A) / 2 << endl;
  }else{
    A--;
    B--;
    N--;
    cout << min(A + (B - A + 1) / 2, (N - B) + (B - A + 1) / 2) << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cassert>
using namespace std;
typedef long long ll;
const int maxn = 3e6 + 10;
const ll mod = 998244353;



ll inv[maxn] ,fac[maxn];


void prec(int n){
	inv[0] = 1;inv[1] = 1;fac[1] = 1;fac[0]= 1;
	for(int i = 2;i <= n;i++) inv[i] = (-inv[mod % i] * (mod / i) % mod + mod) % mod;
	for(int i = 2;i <= n;i++) inv[i] = (inv[i] * inv[i - 1]) % mod,fac[i] = (fac[i - 1] * i) % mod;
}
ll C(ll n,ll m){ if(n < m) return 0;return inv[m] * inv[n - m] % mod * fac[n] % mod;	}



int main(){
	ll n,A,B,k;
	prec(maxn - 1);
	scanf("%lld%lld%lld%lld",&n,&A,&B,&k);
	
	ll ans = 0;
	for(ll a = 0;a <= n;a++){
		ll x = k - a * A;
		if(x < 0) continue;
		if(x % B) continue;
		ll b = x / B;
		if(b > n || b < 0 ) continue; 
		ans = (ans + C(n,a) * C(n,b) % mod) % mod;
	}	
	printf("%lld\n",ans);
}

Measured memory_bytes: 46976
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int h, w, k;
string s[10];
vector< vector< int > > cnt;

int sum(int a, int b, int c, int d){
    return cnt[c][d] - cnt[c][b] - cnt[a][d] + cnt[a][b];
}

int f(int x){
    int res = 0;
    vector<int> p = {0};
    for(int i=0;i<h-1;i++){
        if(((x>>i)&1) == 1){
            res++;
            p.push_back(i+1);
        }
    }
    p.push_back(h);
    int b = 0;
    for(int j=1;j<=w;j++){
        bool flg = false;
        for(int i=1;i<p.size();i++){
            if(sum(p[i-1], b, p[i], j) > k){
                flg = true;
            }
        }
        if(flg){
            if(b == j-1) return 1e9;
            res++;
            b = j-1;
            j--;
        }
    }
    // cout << x << " " << res << endl;
    return res;
}
int main(void){
    cin >> h >> w >> k;
    for(int i=0;i<h;i++) cin >> s[i];
    cnt.assign(h+1, vector<int>(w+1, 0));
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i-1][j-1] == '1') cnt[i][j]++;
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cnt[i][j] += cnt[i][j-1];
        }
    }
    for(int j=1;j<=w;j++){
        for(int i=1;i<=h;i++){
            cnt[i][j] += cnt[i-1][j];
        }
    }

    int ans = h*w;
    for(int i=0;i<(1<<(h-1));i++){
        int tmp = f(i);
        if(tmp < ans) ans = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
'use strict'
function Main(input) {
    input = input.split("\n");
    const n = parseInt(input[0], 10)
    const arr = input[1].split(' ')
    let result = arr[0]
    for (let i = 1; i < n; i++) {
        if (i % 2 === 0 && n % 2 !== 0 || i % 2 !== 0 && n % 2 === 0) {
            result = `${arr[i]} ${result}`
        } else {
            result = `${result} ${arr[i]}`
        }
    }
    console.log(result)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 60080
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;


int main(){
    int r;
    cin >> r;
    cout << (float)PI*2*r;
}


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



int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    vector<int> x(n);
    vector<int> y(n);
    
    rep(i,n) cin >> x[i] >> y[i];
    
    double m = n - 1;
    double paths = 1;
    
    for(int i = 1; i <= m; i++){
        paths *= i;
    }
    
    paths *= 2;
    
    double sum = 0;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < i; j++){
            sum += sqrt((x[i]-x[j]) * (x[i]-x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    sum *= paths;
    
    double ave = 1;
    for(int i = 1; i <= n; i++){
        ave *= i;
    }
    
    cout << fixed << setprecision(10) << sum / ave << endl;
}



Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    A = list(map(int, line_input()))
    B = list(map(int, line_input()))
    C = list(map(int, line_input()))

    ab = round(math.sqrt(pow(A[0] - B[0], 2) + pow(A[1] - B[1], 2)), 15)
    bc = round(math.sqrt(pow(B[0] - C[0], 2) + pow(B[1] - C[1], 2)), 15)
    ca = round(math.sqrt(pow(C[0] - A[0], 2) + pow(C[1] - A[1], 2)), 15)
    S = round(abs((C[0] - A[0]) * (C[1] - B[1]) - (C[1] - A[1]) * (C[0] - B[0])) / 2, 15)
    r = round(S * 2 / (ab + bc + ca), 15)
    longest_side = max([ab, bc, ca])

    x = round(longest_side * r / (2 * r + longest_side),14)
    return x
 
if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 3e5+7;
/*
int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int a[M],tr[M<<2];
int f[M],sz;
void up(int o,int l,int r,int x,int d){
	if(l==r){
		tr[o]=max(tr[o],d);
		return ;
	}
	int m=(l+r)/2;
	if(x<=m)up(ls,l,m,x,d);
	else up(rs,m+1,r,x,d);
	tr[o]=max(tr[ls],tr[rs]);
}
int qu(int o,int l,int r,int x,int y)
{
	if(x<=l&&r<=y){
		return tr[o];
	}
	int m=(l+r)/2,mx=0;
	if(x<=m)mx=max(mx,qu(ls,l,m,x,y));
	if(y>m) mx=max(mx,qu(rs,m+1,r,x,y));
	return mx;
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n,k,sz=0;
  	cin>>n>>k;
  	for(int i=1;i<=n;i++){
  		cin>>a[i];
  		a[i]++;
  		sz=max(sz,a[i]);
	  }
	int mx=0;
	for(int i=1;i<=n;i++){
	//	cout<<a[i]<<" -= -= "<<max(1,a[i]-k)<<"   "<<min(sz,a[i]+k)<<endl;
		int tp=qu(1,1,sz,max(1,a[i]-k),min(sz,a[i]+k))+1;
		up(1,1,sz,a[i],tp);
		mx=max(mx,tp);/*
		for(int j=1;j<=sz;j++)cout<<qu(1,1,sz,j,j)<<" ";
		cout<<" -=-= -  -=-=-= "<<endl;
		cout<<i<<" - "<<tp<<endl;*/
	}

	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 8928
import java.util.Arrays;
import java.util.Scanner;

//Questionnaire
public class Main{

	class R implements Comparable<R>{
		int id, s;
		public R(int id) {
			this.id = id;
		}
		public int compareTo(R o) {
			return s==o.s?id-o.id:o.s-s;
		}
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			R[] r = new R[m];
			for(int i=0;i<m;i++)r[i]=new R(i);
			for(int i=0;i<n;i++)for(int j=0;j<m;j++)r[j].s+=sc.nextInt();
			Arrays.sort(r);
			for(int i=0;i<m;i++){
				if(i>0)System.out.print(" ");
				System.out.print(r[i].id+1);
			}
			System.out.println();
		}
	}

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

Measured memory_bytes: 12000
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}

ll i,j,k,ii,jj;
ll l[500005],r[500005];
ll n,m,num;
ll ans;
ll a,b,c,e,g,h,w,ok,ng;
ll x[500005],y[500005],z[500005];
ll sum[500005],sumxor[500005];
bool flag,dame;
char s[5005];


int main(){
    cin >> n;
    for(i=1;i<=n;i++){
        cin >> x[i];
        sum[i] = sum[i-1] + x[i];
        sumxor[i] = sumxor[i-1] ^ x[i];
    }
    for(i=1;i<=n;i++){
       // pe(i);pe(sum[i]);p(sumxor[i]);
    }
    ll ok,ng;
    for(i=1;i<=n;i++){
        ok = i;
        ng = n + 1;
        while(ng - ok > 1){
            ll mid = (ok + ng) / 2;
            if(sum[mid] - sum[i-1] == (sumxor[mid] ^ sumxor[i-1])){
                ok = mid;
            }else{
                ng = mid;
            }
        }
        ans += (ok - i + 1);
    }
    p(ans);
    //p(ans);
    return 0;
}


Measured memory_bytes: 38144
// Problem : D - Insertion
// Contest : AtCoder - AtCoder Beginner Contest 064
// URL : https://atcoder.jp/contests/abc064/tasks/abc064_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	string s,ans="";
	cin>>s;
	stack <int> st;
	loop(i,n)
	{
		if(st.empty())
			st.push(s[i]);
		else
		{
			if(st.top()=='('&&s[i]==')')
				st.pop();
			else
				st.push(s[i]);
		}
	}
	int open=0,close=0;
	while(!st.empty())
	{
		if(st.top()==')')
			open++;
		else
			close++;
		st.pop();
	}
	loop(i,open)
	ans+="(";
	ans+=s;
	loop(i,close)
	ans+=")";
	cout<<ans<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

int main() {
    int n;
    int c;
    int ans = 0;
    
    cin >> n;
    
    for (int i = 1; i <= n; i += 2) {
        c = 0;
        
        for (int ii = 1; ii <= i; ii++) {
            if ((i % ii) == 0) {
                c++;
            }
        }
        
        if (c == 8) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N;
    int P;
    string S;
    cin >> N >> P >> S;
    if (P == 2 || P == 5) {
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0)
                ans += i + 1LL;
        }
        cout << ans << "\n";
    } else {
        ll ans = 0, sum = 0, factor = 1;
        vector<ll> cnt(P, 0);
        cnt[0]++;
        for (int i = N - 1; i >= 0; i--) {
            sum = (sum + (S[i] - '0') * factor) % P;
            factor = (factor * 10) % P;
            cnt[sum]++;
        }
        for (int p = 0; p < P; p++) {
            ans += (cnt[p] * (cnt[p] - 1)) / 2;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int X, K, R[100010];
int Q;
pii T[100010];

void solve(){
	scanf("%d%d", &X, &K);
	for(int i=1;i<=K;i++) scanf("%d", R+i);
	scanf("%d", &Q);
	for(int i=1;i<=Q;i++) {
		int x, y; scanf("%d%d", &x, &y);
		T[i] = pii(x, y);
	}
	ll L = 0, U = X, O = 0;
	for(int i=1, j=1, tm=0;i<=Q;i++) {
		while(j <= K && R[j] <= T[i].Fi) {
			int dt = R[j] - tm;
			if(j & 1) {
				ll temp = min((ll)dt, O + U);
				O -= temp, L = max(L, -O);
			}
			else {
				ll temp = min((ll)dt, X - O - L);
				O += temp, U = min(U, X - O);
			}
			tm += dt; ++j;
		}
		int dt = T[i].Fi - tm;
		if(j & 1) {
			ll temp = min((ll)dt, O + U);
			O -= temp, L = max(L, -O);
		}
		else {
			ll temp = min((ll)dt, X - O - L);
			O += temp, U = min(U, X - O);
		}
		tm += dt;
		ll a = T[i].Se;
		if(a <= L) printf("%lld\n", L + O);
		else if(L <= a && a <= U) printf("%lld\n", a + O);
		else printf("%lld\n", U + O);
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 2432
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int dp[1005][1005];

int main() {
	int a, b, k[1005], l[1005];
	cin >> a >> b;
	for (int i = 0; i < a; ++i) { cin >> k[i]; }
	for (int i = 0; i < b; ++i) { cin >> l[i]; }
	memset(dp, 999999, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j < b; ++j) {
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + k[i] * l[j]);
			dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]);
		}
	}
	cout << dp[a][b] << endl;
}


Measured memory_bytes: 7060
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
G = [[] for _ in range(n)]
for a, b, c in LIR(n - 1):
    G[a - 1] += [(b - 1, c)]
    G[b - 1] += [(a - 1, c)]

q, k = LI()
dq = deque([k - 1])
dist = [-1] * n
dist[k - 1] = 0
while dq:
    u = dq.pop()
    for v, c in G[u]:
        if dist[v] == -1:
            dist[v] = dist[u] + c
            dq += [v]

for _ in range(q):
    x, y = LI()
    print(dist[x - 1] + dist[y - 1])




Measured memory_bytes: 79316
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0)
      break;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      mp[a] = max(mp[a], b);
    }
    long long ans = 0;
    for (auto &v : mp)
      ans += v.second;
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
	int h,i,m,tmp;
	;
	string A,B,S;

	for(;;){
	cin>>S;
	if(S == "-")
		break;

	cin>>m;
	for(i = 0;i < m;i++){
		cin>>h;

		A = S.substr(0,h);
		B = S.substr(h);
		S = B;
		S += A;
	}
	cout<<S<<endl;
}
return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
const ll MOD = 1e9+7;
const vi dx = {1, 0, -1, 0, 1, -1, -1, 1};
const vi dy = {0, 1, 0, -1, 1, 1, -1, -1};


int main() {
    int H,N; cin>>H>>N;
    vi A(N); 
    rep(i,N) cin>>A[i];

    int sum=0;
    rep(i,N){
        sum += A[i];
    }
    cout<<(sum-H>=0 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    unsigned long long ans = K * pow(K - 1, N - 1);
    cout << ans << endl;
}

Measured memory_bytes: 384
h,w,n = map(int,input().split())
d = {}
for i in range(n):
    a,b = map(int,input().split())
    a,b = a-1,b-1

    am1_f = a-1 > 0
    ap1_f = a+1 < h-1
    bm1_f = b-1 > 0
    bp1_f = b+1 < w-1
    a_f = a > 0 and a < h-1
    b_f = b > 0 and b < w-1

    am1 = a-1
    ap1 = a+1
    bm1 = b-1
    bp1 = b+1

    if am1_f:
        baseid = am1 * w
        if b_f:
            pid = baseid + b

            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bm1_f:
            pid = baseid + bm1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bp1_f:
            pid = baseid + bp1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

    if ap1_f:
        baseid = ap1*w
        if b_f:
            pid = baseid + b

            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bm1_f:
            pid = baseid + bm1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bp1_f:
            pid = baseid + bp1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1
    if a_f:

        baseid = a * w
        if b_f:
            pid = baseid + b
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bm1_f:
            pid = baseid + bm1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1

        if bp1_f:
            pid = baseid + bp1
            if pid not in d:
                d[pid] = 1
            else:
                d[pid] += 1
    # print(d)

ans = [0 for i in range(10)]

for val in d.values():
    ans[val] += 1

ans[0] = (h-2)*(w-2)-sum(ans)

for a in ans:
    print(a)


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

int main() {
    int h, w;
    string s[50];
    bool f;
    
    cin >> h >> w;
    
    rep(i, h) {
        cin >> s[i];
    }
    
    rep(i, h) {
        rep(ii, w) {
            f = true;
            
            if (s[i][ii] == '#') {
                if (
                    ((i == 0) || (s[i - 1][ii] == '.')) &&
                    ((ii == (w - 1)) || (s[i][ii + 1] == '.')) &&
                    ((i == (h - 1)) || (s[i + 1][ii] == '.')) &&
                    ((ii == 0) || (s[i][ii - 1] == '.'))
                ) {
                    f = false;
                }
            }
            
            if (!f) {
                break;
            }
        }
        
        if (!f) {
            break;
        }
    }
    
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    for(i = 0; i < n; i++) {
        cin >> x[i];
    }
    for(i = 0; i < m; i++) {
        cin >> y[i];
    }
    ll retx = 0;
    for(k=0;k<n;k++){
        retx = (retx + k*x[k] - (n-1-k)*x[k])%MOD;
    }
    ll rety=0;
    for(k = 0; k < m; k++) {
        rety = (rety + k * y[k] - (m - 1 - k) * y[k]) % MOD;
    }

    cout << (rety*retx)%MOD << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x0123456789) cerr<<#x0123456789<<':'<<x0123456789<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x0123456789:v)cerr<<x0123456789<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;
typedef long double ld;

signed main(){
    int N,K;
    cin >> N >> K;
    vector<ll> h(N);
    FOR(i,0,N)cin >> h[i];
    sort(ALL(h));
    ll ans = LINF;
    FOR(i,0,N-K+1){
        ans = min(ans,h[i+K-1]-h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/* ex3_3
   KKOO  */

#include <stdio.h>

int main(void) {
    int num,bottom,digits;
    //整数と進数の入力
    scanf("%d %d",&num,&bottom);

    digits = 0;
    //numが0になるまで割れた回数=桁数
    while(num > 0){
        num = num / bottom;
        digits++;
    }

    printf("%d\n",digits);

    return 0;
}


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

count = [0] * 9
for i in a:
    if 1 <= i <= 399:
        count[0] = 1
    elif 400 <= i <= 799:
        count[1] = 1
    elif 800 <= i <= 1199:
        count[2] = 1
    elif 1200 <= i <= 1599:
        count[3] = 1
    elif 1600 <= i <= 1999:
        count[4] = 1
    elif 2000 <= i <= 2399:
        count[5] = 1
    elif 2400 <= i <= 2799:
        count[6] = 1
    elif 2800 <= i <= 3199:
        count[7] = 1
    else:
        count[8] += 1

mx = sum(count[:8]) + count[8]
mn = 0
if sum(count[:8]) == 0 and count[8] != 0:
    mn = 1
else:
    mn = sum(count[:8])

print(mn, mx)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define elif else if
#define rep(i,n) for((int)(i)=0;(i)<(n);++(i))
#define str string
#define Cout(a) cout<<(a)<<endl;
int a,b,c,i,j,k,n,m,x,y,cnt=0,ans=0;
str s,t;

int main(){
  cin>>n>>k>>x>>y;
  Cout(( n<=k?n*x:k*x+(n-k)*y ));
  
  return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll cal(ll *d, ll n)
{
    sort(d, d + n);
    ll tt = 0, s = 0;
    REP(i,n){
        tt = (tt + d[i] * i - s) % MOD;
        s = (s + d[i]) % MOD;
    }
    return (tt + MOD) % MOD;
}

ll d[2][MAXn];

int main()
{
    IOS();
    ll n, m;
    cin>>n>>m;
    REP(i,n)cin>>d[0][i];
    REP(i,m)cin>>d[1][i];
    cout<<cal(d[0], n) * cal(d[1], m) % MOD<<endl;
}


Measured memory_bytes: 1792
#coding:utf-8
import itertools
import numpy as np
from copy import deepcopy

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)


n = 3
oneList = [None for i in range(n)]
value = []
def maker(dep):
    if dep >= n:
        oneList_copy = deepcopy(oneList)
        value.append(oneList_copy)
        return
    oneList[dep] = 1
    maker(dep+1)
    oneList[dep] = -1
    maker(dep+1)

maker(0)


allvalue = []  
for cake in cakeList:
    value8 = [np.dot(v,cake) for v in value]
    allvalue.append(value8)
    
allvalue = np.array(allvalue)

maxList = []
for i in range(2**n):
    row = list(allvalue[:,i])
    row.sort(reverse=True)
    maxv = sum(row[:M])
    maxList.append(maxv)
maxv = max(maxList)
print(maxv)


Measured memory_bytes: 21276
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

N = ni()
status = ["AC","WA","TLE","RE"]
cnt = [0,0,0,0]
for _ in range(N):
    s = ns()
    for i in range(4):
        if s == status[i]:
            cnt[i] += 1


for i in range(4):
    print(status[i] + " x " + str(cnt[i]))

Measured memory_bytes: 68280
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    ll k,x,sum = 0;
    cin>>k>>x;
    sum = k*500;
    if(sum>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << "\n";
}


Measured memory_bytes: 3600
<?php
fscanf(STDIN, "%d", $amout);
$array = explode(' ', fgets(STDIN));

$counter = array();
for($i=0 ; $i < $amout; $i++){
	$value = (int)$array[$i];
	$counter[$value] = !array_key_exists($value, $counter) ? 1 : $counter[$value]+1;
	$counter[$value+1] = !array_key_exists($value+1, $counter) ? 1 : $counter[$value+1]+1;
	$counter[$value-1] = !array_key_exists($value-1, $counter) ? 1 : $counter[$value-1]+1;
}

$answer = 0;
foreach ($counter as $count) {
	$answer = $count > $answer ? $count:$answer;
}

echo $answer;

Measured memory_bytes: 19188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    REP(i, n) {
        cin >> p[i];
        --p[i];
        q[p[i]] = i;
    }
    int x = 0, y = 1;
    for (int i = 1; i < n; ++i) {
        if (q[i - 1] < q[i]) {
            ++y;
        } else {
            x = max(x, y);
            y = 1;
        }
    }
    x = max(x, y);
    cout << n - x << "\n";
    return 0;
}


Measured memory_bytes: 4852
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	string str;
	cin >> str;
	int n = str.size(), g = 1;
	str.insert(str.begin(), '-');
	while (g <= n)
	{
		cout << str[g];
		g += 2;
	}
}

Measured memory_bytes: 3040
#include <iostream>
using namespace std;
int main(void){
    long N,K;
    cin>>N>>K;
    if(K==1) cout<<N*N*N;
    else
    if(K%2==1) cout<<(N/K)*(N/K)*(N/K)<<endl;
    else {long ans=0;
    for(long i=K/2;i<=N;i+=K){
        ans++;
    }
    cout<<ans*ans*ans+(N/K)*(N/K)*(N/K)<<endl;}
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(x => long.Parse(x)).ToArray();
            var tmp = new long[N];
            long ans = 0;
            for(var i = 0; i < N; i++) {
                var d = i - A[i];
                var s = i + A[i];
                if (0 <= d) ans += tmp[d];
                if (s < N) tmp[s]++;
            }
            Console.Write(ans);
        }
    }
}

Measured memory_bytes: 46064
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <time.h>
using namespace std;

typedef long long ll;

int main()
{
    ll ans=1;
    ll N;
    cin >> N;

    vector<ll> is_prime( N + 1 ,1);

    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] ==1)
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                int tmp=j,mul=2;
                while(tmp%i==0){
                    tmp/=i;
                    mul++;
                }
                if(tmp==1) is_prime[j]=mul-1;
                else is_prime[j]*=mul-1;
            }
            is_prime[i]=2;
            // cout << is_prime[i];
        }
        // cout << i << is_prime[i] << endl;
        ans+=i*is_prime[i];
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 81364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  N %= 10;
  if (N == 3)
  {
    cout << "bon" << endl;
  }
  else if (N == 0 || N == 1 || N == 6 || N == 8)
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll N, C, K;
  cin >> N >> C >> K;
  ll t[N];
  for(int i=0;i<N;i++) cin >> t[i];
  sort(t,t+N);

  int ans = 0;
  int ind = 0;
  while(ind < N){
    ll tmp = t[ind] + K;
    int cnt = 1;
    while(cnt < C){
      if(ind + 1 < N && t[ind + 1] <= tmp){
        ind++;
        cnt++;
      }
      else break;
    }
    ind++;
    ans++;
  }

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


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cctype>
using namespace std;

void relay(char op, string &s){

}

int main(){
    int n;
    cin >> n;

    while(n-- > 0){
        string op, s;
        cin >> op >> s;

        reverse(op.begin(), op.end());
        int len = s.length();
        
        for(char x : op){
            if(x == 'J'){
                s = s.substr(len-1, 1) + s.substr(0, len-1);
            }else if(x == 'C'){
                s = s.substr(1) + s.substr(0,1);
            }else if(x == 'E'){
                if(len % 2 == 1){
                    s = s.substr(len/2+1) + s[len/2] + s.substr(0, len/2);
                }else{
                    s = s.substr(len/2) + s.substr(0, len/2);
                }
            }else if(x == 'A'){
                reverse(s.begin(), s.end());
            }else if(x == 'P'){
                for(int i = 0; i < len; i++){
                    if(isdigit(s[i]))   s[i] = '0' + (s[i]-'0'-1+10)%10;
                }
            }else if(x == 'M'){
                for(int i = 0; i < len; i++){
                    if(isdigit(s[i]))   s[i] = '0' + (s[i]-'0'+1)%10;
                }
            }
        }

        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <iostream>
using namespace std;
int main()
{
	char c,cnt=0;
	int C=0,F=0;
	while(cin>>c)
	{
		cnt++;
		if(c=='C'&&C==0)
		C=cnt;
		if(c=='F')
		F=cnt; 
	}
	if(C!=0&&F!=0&&F>C)
	cout<<"Yes";
	else cout<<"No";
	return 0;
	
 } 

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int n;
int main(){
  cin>>n;
  for(int i=1;i<=n;++i){
    int x=i;
    if(x%3==0){
      cout<<" "<<i;
    }else{
      while(x>0){
          if(x%10==3){
             cout<<" "<<i;
             break;
          }
             x=x/10;
      }
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int  main(){
    long long N,M,X;
    cin >> N >> M >> X;
    vector<long long>C(N);
    vector<vector<long long>>A(N,vector<long long>(M));
    for(int i = 0; i < N; i++) {
        cin >> C[i];
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    long long ans = INF;
    for(int i = 0; i < (1<<N); i++) {
        long long cnt = 0;
        vector<long long>ok(M);
        bool flag = true;
        for(int j = 0; j < N; j++) {
            if(1&(i>>j)){
                cnt+=C[j];
                for(int k = 0; k < M; k++) {
                    ok[k]+=A[j][k];
                }
            }
        }
        for(int j = 0; j < M; j++) {
            if(ok[j] < X) {
                flag = false;
            }
        }
        if(flag) {
            ans = min(ans,cnt);
        }
    }
    if(ans == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;

bool cmp(pll a, pll b) {
	if (a.first == b.first) return a.second < b.second;
	return a.first < b.first;
}

struct stlz {
	int h, n;
	vector<ll> t, d;
	void apl(int pos, ll val) {
		t[pos] += val;
		if (pos<n) d[pos] += val;
	}
	void bld(int pos) {
		while (pos>1) {
			pos>>=1;
			t[pos] = max(t[pos<<1], t[pos<<1|1]) + d[pos];
		}
	}
	void psh(int pos) {
		for (int s=h; s>0; --s) {
			int i = pos>>s;
			if (d[i]) {
				apl(i<<1, d[i]);
				apl(i<<1|1, d[i]);
				d[i] = 0;
			}
		}
	}
	void upd(int l, int r, ll val) {
		if (l == r) return;
		l += n; r += n;
		int lt = l, rt = r;
		for (; l<r; l>>=1, r>>=1) {
			if (l&1) apl(l++, val);
			if (r&1) apl(--r, val);
		}
		bld(lt);
		bld(rt-1);
	}
	int qry(int l, int r) {
		l += n; r += n;
		psh(l);
		psh(r-1);
		ll ans = -1e18;
		for (; l<r; l>>=1, r>>=1) {
			if (l&1) ans = max(ans, t[l++]);
			if (r&1) ans = max(ans, t[--r]);
		}
		return ans;
	}
	stlz(vector<ll>& a) {
		n = a.size();
		h = sizeof(int)*8 - __builtin_clz(n);
		t.resize(2*n);
		d.resize(n);
		for (int i=0; i<n; i++) upd(i, i+1, a[i]);
	}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	pll a[n];
	ll lo=1e9, hi=-1e9;
	for (int i=0; i<n; i++) {
		cin >> a[i].first >> a[i].second;
		lo = min(lo, a[i].second);
		hi = max(hi, a[i].second);
	}
	sort(a, a+n, cmp);
	
	vector<ll> vec(n);
	for (int i=0; i<n; i++) {
		vec[i] = (a[i].first-a[0].first) + (a[i].second-lo);
	}
	stlz low(vec);
	for (int i=0; i<n; i++) {
		vec[i] = (a[i].first-a[0].first) + (hi-a[i].second);
	}
	stlz hig(vec);
	
	ll ans = 0;
	for (int i=0; i<n; i++) {
		ll dx = 0;
		if (i) dx = a[i].first-a[i-1].first;
		low.upd(i, n, -dx);
		hig.upd(i, n, -dx);
		
		ll cur = 0;
		cur = max(cur, low.qry(i, n) - (a[i].second - lo));
		cur = max(cur, hig.qry(i, n) - (hi - a[i].second));
		ans = max(ans, cur);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 17176