akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	mod := 998244353
	Dn := make([]int, N)
	var maxD, ans int
	for i := range Dn {
		Dn[i] = nextInt()
		maxD = MaxOf(maxD, Dn[i])
	}
	if Dn[0] != 0 {
		fmt.Println(0)
		return
	}
	nodes := make([][]int, maxD+1)
	for i := 0; i < N; i++ {
		nodes[Dn[i]] = append(nodes[Dn[i]], i)
	}
	if len(nodes[0]) > 1 {
		fmt.Println(0)
		return
	}
	ans = 1
	// fmt.Println(ans)
	for i := 2; i < len(nodes); i++ {
		if len(nodes[i]) == 0 {
			fmt.Println(0)
			return
		}
		tmp := len(nodes[i-1])
		for j := 0; j < len(nodes[i])-1; j++ {
			tmp *= len(nodes[i-1])
			tmp %= mod
		}
		ans *= tmp
		ans %= mod
		// fmt.Println(ans)
	}
	// fmt.Println(Dn, nodes, mod)
	fmt.Println(ans)
}

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

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 5504
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)

num=list(map(int,input().split()))
A=num[0]
B=num[1]
S=lcm(A,B)
print(S)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    string s;
    cin>>a>>b>>s;

    bool f=true;
    if(s[a]!='-')f=false;
    rep(i,a)if(!isdigit(s[i]))f=false;
    rep(i,b)if(!isdigit(s[a+1+i]))f=false;
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
ll mod;
const int mn=6e3+10;
ll fact[mn],ifact[mn],pi2[mn],pi6[mn],p2[mn];
ll po(ll a,ll b=mod-2){
    ll ans=1;
    for(;b;b>>=1,a*=a,a%=mod)if(b&1)ans*=a,ans%=mod;
    return ans;
}
int main(){
    int n;
    cin>>n>>mod;
    fact[0]=ifact[0]=pi2[0]=pi6[0]=p2[0]=1;
    for(int i=1;i<=3*n;i++)fact[i]=fact[i-1]*i%mod,ifact[i]=po(fact[i]),p2[i]=p2[i-1]*2%mod;
    pi2[1]=po(2),pi6[1]=po(6);
    for(int i=2;i<=3*n;i++)pi2[i]=pi2[i-1]*pi2[1]%mod,pi6[i]=pi6[i-1]*pi6[1]%mod;
    ll ans=0;
    for(int i=0;i<=n;i++)for(int j=0;i+j<=n;j++){
        ans+=fact[3*n]*pi6[i]%mod*pi2[j]%mod*ifact[i]%mod*ifact[j]%mod*ifact[3*n-3*i-2*j]%mod*p2[i]%mod;
        ans%=mod;
    }
    printf("%lld",ans);
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using graph=vector<vector<int>>;

vector<int> distance(const graph& G,int s){
	const int INF=INT_MAX;
	int n=G.size();
	vector<int> d(n,INF);
	d[s]=0;
	queue<int> Q; Q.emplace(s);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		for(int v:G[u]) if(d[v]==INF) {
			d[v]=d[u]+1;
			Q.emplace(v);
		}
	}
	return d;
}

int main(){
	int n,x,y; scanf("%d%d%d",&n,&x,&y); x--; y--;
	graph G(n);
	rep(i,n-1){
		G[i].emplace_back(i+1);
		G[i+1].emplace_back(i);
	}
	G[x].emplace_back(y);
	G[y].emplace_back(x);

	vector<vector<int>> d(n);
	rep(u,n) d[u]=distance(G,u);

	vector<int> ans(n);
	rep(u,n) rep(v,u) ans[d[u][v]]++;
	for(int i=1;i<n;i++) printf("%d\n",ans[i]);

	return 0;
}


Measured memory_bytes: 16128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
#include <list>

using namespace std;

int gcd(int a, int b){
    if (a<b) swap(a,b);
    int q, r;
    do{
        q = a / b;
        r = a % b;
        a = b;
        b = r;
    }
    while(r!=0);
    return a;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cities(n);
    vector<int> vec(m * 2);
    for(int i = 0; i < m * 2; i++){
        cin >> vec[i];
        cities[vec[i] - 1] += 1;
    }
    
    rep(i, n){
        cout << cities[i] << endl;
    }
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define pb push_back
#define eb emplace_back


template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

using mint = modint<1000000007>;

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    ll n,w;
    cin >> n >> w;
    vector<pair<ll,ll>> wv(n);
    for(ll i = 0; i<n; i++){
        cin >> wv[i].first >> wv[i].second;
    }
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
    for(ll i = 0; i<n; i++){
        for (ll j = 0; j< w+1; j++){
            dp[i+1][j]=dp[i][j];
            if(j-wv[i].first>=0){
                chmax(dp[i+1][j],dp[i][j-wv[i].first]+wv[i].second);
            }
        }
    }
    cout << dp[n][w] << '\n';
}

Measured memory_bytes: 80256
# Aizu Problem 0280: The Outcome of Bonze

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n = int(input())
    if n == 0:
        break
    cards = [_ for _ in input().strip()]
    players = [0] * n
    table = 0
    player = 0
    for k in range(100):
        card = cards[k]
        if card == 'M':
            players[player] += 1
        elif card == 'S':
            table += 1 + players[player]
            players[player] = 0
        elif card == 'L':
            players[player] += 1 + table
            table = 0
        player = (player + 1) % n
    players = sorted(players)
    players.append(table)
    print(' '.join([str(p) for p in players]))

Measured memory_bytes: 7836
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int DP[101], DP2[101];
int n, t[100], v[100];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> t[i];
  FOR(i, 0, n) cin >> v[i];
  FOR(q, 0, 105){
    FOR(i, 1, n){
      DP2[i] = iinf;
      mins(DP2[i], v[i-1]);
      mins(DP2[i], v[i]);
      mins(DP2[i], DP[i-1] + t[i-1]);
      mins(DP2[i], DP[i+1] + t[i]);
    }
    swap(DP, DP2);
  }
  double ans = 0.;
  FOR(i, 0, n){
    int l = DP[i], r = DP[i+1];
    if(l > r) swap(l, r);
    if(t[i]-r+l <= (v[i]-r) * 2){
      ans += double((l*2+t[i]) * t[i]) / 2 - double((l+t[i]-r)*(l+t[i]-r)) / 4;
    }else{
      ans += double((l+v[i])*(v[i]-l) + (r+v[i])*(v[i]-r)) / 2 + double(v[i] * (t[i]+l+r-2*v[i]));
    }
  }
  dout(ans);
  return 0;
}

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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int H, W, K; cin >> H >> W >> K;
	vector<vector<char>> c(H, vector<char>(W));
	int tot = 0;
	rep(i, H)rep(j, W) {
		cin >> c[i][j];
		if (c[i][j] == '#')tot++;
	}

	int ans = 0;
	stack<vector<bool>> s;
	s.emplace();

	while (!s.empty()) {
		auto now = s.top();
		s.pop();

		if (now.size() == H + W) {
			int n = 0;
			auto d = c;
			rep(i, H) {
				if (now[i] == false)continue;
				rep(j, W) { if (d[i][j] == '#')d[i][j] = '*'; }
			}
			rep(j, W) {
				if (now[H + j] == false)continue;
				rep(i, H) { if (d[i][j] == '#')d[i][j] = '*'; }
			}
			rep(i, H)rep(j, W)if (d[i][j] == '*')n++;
			if (K == tot - n)ans++;
		}
		else {
			auto next = now;
			next.push_back(false);
			s.push(next);
			next = now;
			next.push_back(true);
			s.push(next);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#define maxn 1000006
using namespace std;
int a[maxn], sl[maxn], sr[maxn];
int aabs(int x){
	return x >= 0 ? x : -x;
}
int read(){
	int cnt = 0, flag = 1;
	char ch = getchar();
	while ((ch < '0' || '9' < ch) && ch != '-')
		ch = getchar();
	if (ch == '-'){
		flag = -1;
		ch = getchar();
	}
	while ('0' <= ch && ch <= '9'){
		cnt = cnt * 10 + ch - '0';
		ch = getchar();
	}
	return cnt * flag;
}
int main(){
	int n = read();
	for (int i = 1; i <= n; ++ i)
		a[i] = read();
	for (int i = 1; i <= n; ++ i)
		sl[i] = sl[i - 1] + aabs(a[i] - a[i - 1]);
	for (int i = n; i; -- i)
		sr[i] = sr[i + 1] + aabs(a[i] - a[i + 1]);
	for (int i = 1; i <= n; ++ i)
		printf("%d\n", sl[i - 1] + sr[i + 1] + aabs(a[i - 1] - a[i + 1]));
	return 0;
}


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

int main() {
int a,b;
    cin >> a >> b;
    
    if(a > b) {
     rep(i,a) {
     cout << b;
     }
    }
    else if (b > a) {
    rep(i,b) {
    cout << a;
    }
    }
        else {
        rep(i,a) {
        cout << a;
        }
        }
        
}

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

#define NL '\n'
#define mem(a, b) memset(a, b, sizeof(a))
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int main(){
	async(); int n; 
	cin >> n;
	long long a[n+1];
	a[0] = 2, a[1] = 1;
	for(int i = 2; i <= n; i++) a[i] = a[i-1] + a[i-2];
	cout << a[n] << NL;
} 

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
  string S;
  cin >> S;

  for (int i = 0; i < S.length(); i++)
  {
    cout << "x";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
int main(){
    string s,t;
    cin>>s>>t;
    string INF = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    string ans = INF;
 
    for(int i=0;i + t.size() <= s.size();i++){
        bool can = true;
        for(int j=0;j<t.size();j++){
            can &= (s[i+j] == t[j] || s[i+j] == '?');
        }
        if(can){
            string res = s;
            for(int j=0; j < t.size();j++){
                    res[i+j] = t[j];
                }
            for(char& c : res){
                if(c == '?') c  = 'a';
            }
            ans = min(res,INF);
        }
    }
    if(ans==INF) cout<<"UNRESTORABLE\n";
    else cout<<ans<<endl;
 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int h,n,a,sum=0;
    cin>>h>>n;
    rep(i,1,n) {
        cin>>a;
        sum+=a;
    }
    if(sum>=h) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
}



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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  map<string,int> red, blue;

  rep(i, n) {
    string s; cin >> s;
    ++red[s];
  }

  int m; cin >> m;
  rep(i, m) {
    string s; cin >> s;
    ++blue[s];
  }

  int ans = 0;
  for (auto e : red) {
    int score = e.se;
    score -= blue[e.fi];

    chmax(ans, score);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
class Program{
	const int mod=1000000007;
	static long[] dat;
	static int m=1;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] h=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		while(m<=n+1){m*=2;}
		dat=new long[m+n];
		long ans=a[0];
		fdu(h[0],a[0]);
		for(int i=1;i<n;i++){
			long p=fdg(0,h[i]-1,0,0,m-1)+a[i];
			fdu(h[i],p);
			ans=Math.Max(ans,p);
		}
		Console.WriteLine(ans);
	}
	static void fdu(int q,long b){
		q+=m-1;
		dat[q]=b;
		while(q>0){
			dat[(q-1)/2]=Math.Max(dat[(q-1)/2],b);
			q=(q-1)/2;
		}
	}
	static long fdg(int a,int b,int k,int l,int r){
		if(r<a||b<l){return -1;}
		if(a<=l&&r<=b){return dat[k];}
		else{return Math.Max(fdg(a,b,k*2+1,l,(l+r)/2),fdg(a,b,k*2+2,(l+r+1)/2,r));}
	}
}

Measured memory_bytes: 46264
n, m = map(int, input().split())
a=list()
b=list()
for x in range(n):
    a.append(list(map(int, input().split())))
for y in range(m):
    b.append(int(input()))
for za in range(n):
    c=0
    for zb in range(m):
        c+=a[za][zb]*b[zb]
    print(c)
    



Measured memory_bytes: 6004
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<numeric>
using namespace std;
typedef long long int lli;
#define rep(i,n) for(lli i = 0;i<((lli)(n));i++)
#define reg(i,a,b) for(lli i = ((lli)(a));i<=((lli)(b));i++)
#define irep(i,n) for(lli i = ((lli)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(lli i = ((lli)(b));i>=((lli)(a));i--)
typedef pair<lli, lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprllif(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD 1000000007

lli f[100005];
void ff(void){
	f[0] = 1;
	reg(i, 1, 100000) f[i] = (f[i-1]*i)%MOD;
	return;
}

lli rev(lli a){
	lli b[32], ret = 1; b[0] = a;
	reg(i, 1, 31) b[i] = (b[i-1]*b[i-1])%MOD;
	rep(i, 32) if(((MOD-2)>>i) & 1) ret = (ret*b[i])%MOD;
	return ret;
}

lli comb(lli m, lli r){
	if(m < r || m == 0) return 0;
	return (((f[m]*rev(f[r]))%MOD)*rev(f[m-r]))%MOD;
}

int main(void){
	int n, a, b, c;
	cin >> n;
	vector<int> v(n+1, -1);
	rep(i, n+1){
		int t; cin >> t;		
		if(v[t] != -1){
			a = v[t];
			b = i-v[t]-1;
			c = n-i;
			break;
		}else v[t] = i;
	}
	
	ff();
	
	cout << n << endl;
	reg(k, 2, n){
		lli ans = comb(n, k) + comb(n-1, k-2) + comb(n-1, k-1) - comb(a+c, k-1);
		while(ans < 0) ans += MOD;
		cout << ans%MOD << endl;
	}
	cout << 1 << endl;
	
	return 0;
}

Measured memory_bytes: 2432
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AAC {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        if (s == "ABC") {
            cout << "ARC" << endl;
        } else {
            cout << "ABC" << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AAC solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char W[10], T[5];
    int count = 0, i;
    scanf("%s", W);
    while (scanf("%s", T) != EOF && strcmp(T, "END_OF_TEXT")) {
        for (i = 0; T[i]; i++) {
            T[i] = tolower(T[i]);
        }
        if (!strcmp(W, T)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 548
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int ans=a+b;
    if(ans<a-b)ans=a-b;
    if(ans<a*b)ans=a*b;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int h,w;
        while(true){
            h = scan.nextInt();
            w = scan.nextInt();
            if(h == 0 && w == 0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i == 0 || i == h-1 || j == 0 || j == w-1) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  set<pair<ll,ll>> memo;
  memo.insert(pair<ll,ll>(a,b));
  int ans = 0;
  for(;a%2==0&&b%2==0&&c%2==0;ans++) {
    ll a2=a/2;
    ll b2=b/2;
    ll c2=c/2;
    a=b2+c2;
    b=a2+c2;
    c=a2+b2;
    if(memo.count(pair<ll,ll>(a,b))) {
      cout << -1 << endl;
      return 0;
    }
    memo.insert(pair<ll,ll>(a,b));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
// whats 1000 minus 7 ?
#include <bits/stdc++.h>
using namespace std;
inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
inline string get(){char ch[1000010] ; scanf("%s",ch) ; return ch;}
const int MAX_LG = 60;
#define x first
#define y second
#define int long long
#define eps 1e-9
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef pair<int , int > pii;
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
const int maxn = 2e6 + 100;
const int base = 29;
const int mod = 1e9 + 7;
const int INF = 1e18 + 100;
int res;
int a[maxn];
int32_t main()
{
    int n = in() * 2;
    for (int i = 0 ; i < n ; i ++) a[i] = in();
    sort(a,a+n);
    for (int i = 0 ; i < n ; i += 2)res += a[i];
    cout << res << endl;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) cin >> s[i] >> c[i];
    int mn = (n != 1 ? pow(10, n - 1) : 0), mx = pow(10, n);
    if(m == 0) {
        cout << mn << endl;
        return 0;
    }
    FOR(i, mn, mx) {
        rep(j, m) {
            int x = (i / (int)pow(10, n - s[j])) % 10;
            if(x != c[j]) break;
            if(j == m - 1) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  ull n;
  vector<ull> b;
  cin >> n;

  each(i, n) {
    ull tmp;
    cin >> tmp;
    b.push(tmp);
  }

  vector<ull> result;
  while (!b.empty()) {
    auto matched = -1;
    each(i, b.size()) {
      if (b[i] == (i+1)) {
        matched = i;
      }
    }

    if (matched == -1) {
      cout << -1 << endl;
      return 0;
    } else {
      result.push(matched+1);
      b.erase(b.begin() + matched);
    }
  }

  reverse(result.begin(), result.end());
  for (auto v : result) {
    cout << v << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    int r;
    vector<int> d;
    ll ans = 0;

    cin >> r;

    ans = 3 * r * r; 
    cout << ans << endl;
    
}


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

int main(){
  int N;
  cin >> N;
  
  int A[N];
  
  for(int i = 0; i < N; i++) cin >> A[i];
  
  int count = 0;
  bool init = true;
  bool flag;
  for(int i = 0; i < N-1; i++){
    if(init == true){
      if(A[i] < A[i + 1]){
      init = false;
      flag = true;
      }else if(A[i] > A[i + 1]){
      init = false;
      flag = false;
      }
    }else{
      if(flag == true && A[i] > A[i+1]){
        flag = false;
        init = true;
        count++;
      }else if(flag == false && A[i] < A[i+1]){
        flag = true;
        init = true;
        count++;
      }
    }
  }
  cout << count + 1;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll,ll>
    #define msi           map<string,ll>
    #define mis           map<ll,string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll,ll>>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define hi            cout<<"hi"<<endl;
    const ll maxn=200005;
    void solve()
    {
      ll k;
      cin>>k;
      queue<ll> q;
      rep(i,1,10) q.push(i);
      ll t;
      while(k--)
      {
        t=q.front();
        q.pop();
        if(t%10!=0)
          q.push(t*10+t%10-1);
        q.push(t*10+t%10);
        if(t%10!=9) q.push(t*10+t%10+1);
      }

      cout<<t<<endl;


    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //#ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        //#endif
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }
    
  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
int n,a[N];
int main() {
    ios::sync_with_stdio(false);
    int res=0;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[i]==res+1){
            res++;
        }
    }
    if(res==0)cout<<-1<<endl;
    else cout<<n-res<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[405],dp[405][405],s[405];
int main(){
	cin >> n;
	memset(dp,0x7f,sizeof(dp));
	for (int i=1;i<=n;++i){
		cin >> a[i];
		s[i]=s[i-1]+a[i];
	}
	for (int i=1;i<=n;++i) dp[i][i]=0;
	for (int l=1;l<n;++l){
		for (int x=1;x+l<=n;++x){
			for (int m=x;m<x+l;++m){
    			dp[x][x+l]=min(dp[x][x+l],dp[x][m]+dp[m+1][x+l]);
			}
			dp[x][x+l]+=s[x+l]-s[x-1];
		}
	}
	cout << dp[1][n] << endl;
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int N;

	cin >> N;

	int sum = 0;

	for (int i = 1; i < N + 1; i++) {
		sum += i;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define f first
#define s second
#define eb emplace_back
#define sz(s) ((int) s.size ())
#define all(s) (s.begin (), s.end ())

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 5;
const int mod = (int) 1e9 + 7;

double d[N], ans[N];
vector<int> g[N];
int n;

void dfs (int v, int p = -1) {
        d[v] = 0;
        for (int to : g[v]) {
                if (to != p) {
                        dfs (to, v);
                        if (sz (g[to]) > 1) {
                                d[v] += d[to] / (sz (g[to]) - 1);
                        }
                }
        }
        d[v] += sz (g[v]) - (p != -1);
}

void sdfs (int v, int p = -1, double u = 0) {
//        printf ("%d %.6f\n", v, u);
        ans[v] = (u + d[v]) / sz (g[v]);
        for (int to : g[v]) {
                if (to != p) {
                        double cur = d[v] + u - 1;
                        if (sz (g[to]) > 1) {
                                cur -= d[to] / (sz (g[to]) - 1);
                        }
                        if (sz (g[v]) > 1) {
                                cur /= sz (g[v]) - 1;
                        }
                        sdfs (to, v, cur + 1);
                }
        }
}

inline void solve () {
        scanf ("%d", &n);
        for (int i = 1; i < n; i++) {
                int x, y;
                scanf ("%d%d", &x, &y);
                g[x].emplace_back (y);
                g[y].emplace_back (x);
        }
        dfs (1); sdfs (1);
        for (int i = 1; i <= n; i++) {
                printf ("%.6f\n", ans[i]);
        }
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 19456
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  int n = 3;
  string s;
  cin >> s;

  sort(s.begin(), s.end());
  if (s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int i,count=0;
   char num[4];
   for(i=0;i<4;i++)
   num[i]=0;
   
    scanf("%s",&num);
    
    for(i=0;i<3;i++)
    if(num[i]=='1')
    count++;
    
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
# C問題
n = int(input())
S = []
for i in range(n):
    S.append(input())
base = min(S, key = len)
S.remove(base)
ans = []
for i in range(len(base)):
    flag = True
    for k in range(len(S)):
        if base[i] not in S[k]:
            flag = False
        else:
            place = S[k].find(base[i])
            S[k] = S[k].replace(base[i], '', 1)            
    if flag:
        ans.append(base[i])
ans.sort()
char_ans = ''
for i in range(len(ans)):
    char_ans += ans[i]
print(char_ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fa hi][0
#define sz hi][1
#define son hi][2
#define dep hi][3
#define top hi][4
#define id hi][5
const int N=1e5+7;
int n;
struct edge{
	int to,nx;
}e[N*2];
int e0[N],ep=2,idr[N];
int hi[N][8],idp=0;
void f1(int w,int pa){
	w[dep]=pa[dep]+1;
	w[fa]=pa;
	w[sz]=1;
	for(int i=e0[w];i;i=e[i].nx){
		int u=e[i].to;
		if(u==pa)continue;
		f1(u,w);
		w[sz]+=u[sz];
		if(u[sz]>w[son][sz])w[son]=u;
	}
}
void f2(int w,int tp){
	w[top]=tp;
	w[id]=++idp;
	idr[idp]=w;
	if(w[son])f2(w[son],tp);
	for(int i=e0[w];i;i=e[i].nx){
		int u=e[i].to;
		if(u!=w[fa]&&u!=w[son])f2(u,u);
	}
}
int ps[N][2],ed[N];
int min(int a,int b){return a<b?a:b;}
int _l,_r,_w;
struct node{
	node*lc,*rc;
	int L,R,M;
	int mn,a;
	std::vector<int>vs;
	void up(){mn=min(lc->mn,rc->mn);}
	void add(int x){mn+=x,a+=x;}
	void dn(){if(a)lc->add(a),rc->add(a),a=0;}
	void ins(){
		if(_l<=L&&R<=_r)return vs.push_back(_w),add(1);
		dn();
		if(_l<=M)lc->ins();
		if(_r>M)rc->ins();
		up();
	}
	void del(){
		if(_l<=L&&R<=_r)return add(-1);
		dn();
		if(_l<=M)lc->del();
		if(_r>M)rc->del();
		up();
	}
	void gmn(){
		while(vs.size()&&ed[vs.back()])vs.pop_back();
		if(vs.size())_w=vs.back(),vs.pop_back();
		if(L==R){
			mn=0x3f3f3f3f;
			return;
		}
		dn();
		(mn==lc->mn?lc:rc)->gmn();
		up();
	}
}ns[N*2],*np=ns,*rt;
node*build(int L,int R){
	node*w=np++;
	w->L=L,w->R=R;
	if(L<R){
		int M=w->M=L+R>>1;
		w->lc=build(L,M);
		w->rc=build(M+1,R);
		w->up();
	};
	return w;
}
void ins(int x,int y){
	int a=x[top],b=y[top];
	while(a!=b){
		if(a[dep]<b[dep])std::swap(a,b),std::swap(x,y);
		_l=a[id],_r=x[id],rt->ins();
		x=a[fa],a=x[top];
	}
	if(x[dep]>y[dep])std::swap(x,y);
	if(x!=y)_l=x[id]+1,_r=y[id],rt->ins();
}
void del(int x,int y){
	int a=x[top],b=y[top];
	while(a!=b){
		if(a[dep]<b[dep])std::swap(a,b),std::swap(x,y);
		_l=a[id],_r=x[id],rt->del();
		x=a[fa],a=x[top];
	}
	if(x[dep]>y[dep])std::swap(x,y);
	if(x!=y)_l=x[id]+1,_r=y[id],rt->del();
}
int main(){
	scanf("%d",&n);
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		e[ep]=(edge){b,e0[a]};e0[a]=ep++;
		e[ep]=(edge){a,e0[b]};e0[b]=ep++;
	}
	f1(1,0),f2(1,1);
	rt=build(2,n);
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		ps[i][0]=a,ps[i][1]=b,_w=i;
		ins(a,b);
	}
	for(int i=1;i<n;++i){
		if(rt->mn!=1)return puts("NO"),0;
		rt->gmn();
		ed[_w]=1;
		del(ps[_w][0],ps[_w][1]);
	}
	return puts("YES"),0;
}

Measured memory_bytes: 34156
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    int sum=0;
    for(int i=n-1;i>0;i--){
        sum+=i;
    }
    for(int i=m-1;i>0;i--){
        sum+=i;
    }
    cout << sum ENDL;
    
    return 0;
}

Measured memory_bytes: 3644
num = int(input())

s = [1,2,3,4,5,6,7,8,9,10,11,12,13]
h = [1,2,3,4,5,6,7,8,9,10,11,12,13]
c = [1,2,3,4,5,6,7,8,9,10,11,12,13]
d = [1,2,3,4,5,6,7,8,9,10,11,12,13]

while True:
    try:
        m,n = input().split()
        if m == "S":
            del s[s.index(int(n))]
        elif m == "H":
            del h[h.index(int(n))]
        elif m == "C":
            del c[c.index(int(n))]
        elif m == "D":
            del d[d.index(int(n))]
    except:
        break

if len(s) > 0:
    for i in range(len(s)):
        print("S " + str(s[i]))

if len(h) > 0:
    for i in range(len(h)):
        print("H " + str(h[i])) 

if len(c) > 0:
    for i in range(len(c)):
        print("C " + str(c[i]))

if len(d) > 0:
    for i in range(len(d)):
        print("D " + str(d[i]))


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans[n] = {};
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') cnt++;
        else {
            ans[i - 1] += (cnt + 1) / 2;
            ans[i] += cnt / 2;
            cnt = 0;
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'L') cnt++;
        else {
            ans[i + 1] += (cnt + 1) / 2;
            ans[i] += cnt / 2;
            cnt = 0;
        }
    }
    rep(i, 0, n) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <map>
#include <ctime>
#include <list>
#include <bitset>
#include <algorithm>

#define ll long long
#define v vector
#define fos(i, s, c) for (int i = s; i != c; i++)

using namespace std;

int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	v<v<int>> input(n, v<int>(3));
	for (auto& it1 : input)
		for (auto& it : it1)
			cin >> it;
	v<v<int>> dp(n, v<int>(3, 0));
	dp[0][0] = input[0][0];
	dp[0][1] = input[0][1];
	dp[0][2] = input[0][2];
	fos(i, 1, n)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + input[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + input[i][1];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + input[i][2];
	}
	int max = 0;
	for (auto it : dp[n - 1])
		max = std::max(max, it);
	cout << max;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, X;
  cin >> A >> B >> C;
  X = A + B + C;
  if(X >= 22) {
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
}

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

using namespace std;

int main(){
 
  int n, d;
  int x[10][20] = {{0}};
  int ans = 0;
  float sum = 0;

  cin >> n >> d;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }

  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      sum = 0;
      for(int k = 0; k < d; k++){
	sum += pow(x[i][k] - x[j][k], 2);
      }

      float root = sqrt(sum);

      if(root - (int)root == 0){
	ans++;
      }

    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (a,b) = get!(i32,i32);

    match a {
        6...12 => println!("{}" ,b/2),
        0...5  => println!("0"),
        _      => println!("{}",b),
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int count[4][3][10];
  int n,b,f,r,v;
  int x,y,z,i;
  for( x = 0; x < 4;x++){
    for( y = 0; y < 3;y++){
      for( z = 0; z < 10;z++){
        count[x][y][z]=0;
      }
    }
  }
  scanf("%d", &n);
  for( i = 0; i < n; i++){
    scanf("%d%d%d%d", &b, &f, &r, &v);
    count[b-1][f-1][r-1] += v;
    if( count[b-1][f-1][r-1] > 9 || count[b-1][f-1][r-1] < 0){
      return 0;
    }

  }
  for( x = 0; x < 4;x++){
    for( y = 0; y < 3;y++){
      for( z = 0; z < 10;z++){
        printf(" %d", count[x][y][z]);
      }
      printf("\n");
    }
    if( x <= 2)
      printf("####################\n");
  }
  return 0;
}






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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<typename T>
class SegmentTree {
    using Func = std::function<T(T, T)>;
    private:
        const Func F;
        const T DEF;
        int N;
        std::vector<T> dat;
    public:
        SegmentTree(int n, const Func f, const T def) : F(f), DEF(def) {
            N = 1;
            while (N < n) {
                N *= 2;
            }
            dat = std::vector<T>(2*N, DEF);
        }
        void set(int a, const T v) {
            dat.at(a+N) = v;
        }
        void build() {
            for (int i=N-1; i>0; i--) {
                dat.at(i) = F(dat.at(2*i), dat.at(2*i+1));
            }
        }
        void update(int a, const T v) {
            int cur = a + N;
            dat.at(cur) = v;
            while (cur >>= 1) {
                dat.at(cur) = F(dat.at(2*cur), dat.at(2*cur+1));
            }
        }
        T get(int a, int b) {
            T vleft = DEF, vright = DEF;
            for (int left=a+N, right=b+N; left<right; left>>=1, right>>=1) {
                if (left & 1) {
                    vleft = F(vleft, dat.at(left++));
                }
                if (right & 1) {
                    vright = F(vright, dat.at(--right));
                }
            }
            return F(vleft, vright);
        }
};

long long gcd(long long a, long long b) {
    if (a < b) {
        std::swap(a, b);
    }
    if (b == 0) {
        return a;
    }
    while (a%b > 0) {
        long long buf = b;
        b = a%b;
        a = buf;
    }
    return b;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    SegmentTree<ll> seg(n, ::gcd, 0ll);
    for (int i=0; i<n; i++) {
        seg.set(i, a.at(i));
    }
    seg.build();
    ll ans = -1;
    for (int i=0; i<n; i++) {
        ans = max(ans, gcd(seg.get(0, i), seg.get(i+1, n)));
    }
    cout << ans << endl;
    return 0;
}


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

struct unitefriend{
  vector<int> r;

  unitefriend(int N){
    r = vector<int>(N, -1);
  }

  int root(int x){
    if(r[x] < 0){
      return x;
    }else{
      return r[x] = root(r[x]);
    }
  }

  void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x != y){
      r[x] += r[y];
      r[y] = x;
    }
  }

  int size(int x){
    return -r[root(x)];
  }
};

int main() {

  ll N, M;
  cin >> N >> M;

  unitefriend uf(N);

  int tmp1, tmp2;
  for(int i = 0; i < M; i++){
    cin >> tmp1 >> tmp2;
    uf.unite(tmp1 - 1, tmp2 - 1);
  }

  int max = 0;
  for(int i = 0; i < N; i++){
    if(uf.size(i) > max){
      max = uf.size(i);
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 4332