akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*
vector<string> v(n, string(m,"*"));
vector<vector<int>>
*/
int main() {
	long long a, c,e;
	float b;
	int i, d=0;

	cin >> a >> b;
	c = a;
	while (c != 0) {
		c = c / 10;
		++d;
	}
	c = a;
	e = (long long)(b * 100.1);
	//cout << e << endl;
	vector<long long> r(d);
	for (i = 0; i < d; i++){
		
		r[i] = (c % 10) * e;
		c /= 10;
		//cout << r[i] << endl;
	}
	c = 0;
	for (i = 0; i < d; i++) {
		c += r[i]*(long long)pow(10, i);
	}
	cout << c/100 << endl;


	return 0;
}

Measured memory_bytes: 4184
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}

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


	ll n,u,v;
	cin>>n>>u>>v;
	u--;v--;
	Graph g(n);

	REP(i,n-1){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		add_edge(g,a,b,1,true,1);
	}
	Array d;
	Dijkstra(g,v,d);

	Array dt;
	Dijkstra(g,u,dt);

	ll ans=0;
	ll min=INF;

	REP(i,n){
		if(d[i]>dt[i]){
			chmax(ans,d[i]-1);
		}

	}
	//cout<<ans<<min<<endl;

	if(min!=INF) chmin(ans,min);
	cout<<ans<<endl;

	return 0;
}




Measured memory_bytes: 12168
class RhoSequence:
    """
    A_1 = start, A_{i+1} = f(A_i) で、かつA_i が一定の整数の範囲内に収まるような数列に対するクエリを処理するクラス

    例：A_1=3, f(x)=x*x%7 -> A_2=2, A_3=4, A_4=2, A_5=4, ...
    """

    def __init__(self, f, start, val_max, val_min=0):
        self.f = f
        self.start = start
        self.val_max = val_max
        self.val_min = 0

        width = val_max - val_min + 1
        n = [-1] * width
        n[start-val_min] = 1
        route = [start] # A_1 からループが見つかるまでA_iの値を格納するリスト
        loop_start_n = -1 # ループがどこから始まったか
        x = start
        for i in range(2, width):
            fx = f(x)
            if n[fx] != -1:
                loop_start_n = n[fx]
                break
            route.append(fx)
            n[fx] = i
            x = fx
        self.route = route
        self.route_before_loop = route[:loop_start_n-1]
        self.loop_start_n = loop_start_n
        self.cycle = self.route[loop_start_n-1:]
        self.cycle_length = len(self.cycle)
    
    def get_nth_value(self, n):
        """
        n番目の数 A_n を返す
        """
        if n < self.loop_start_n:
            # nがループ開始より前の場合
            return self.route_before_loop[n-1]
        
        n -= self.loop_start_n
        return self.cycle[n%self.cycle_length]

    def sum_until_n(self, n):
        """
        A_1 から A_n までの合計を返す
        """
        if n < self.loop_start_n:
            # nがループ開始より前の場合
            return sum(self.route_before_loop[:n])

        ret = sum(self.route_before_loop)
        n -= self.loop_start_n - 1
        n_loop = n // self.cycle_length
        ret += n_loop * sum(self.cycle)
        n -= n_loop * self.cycle_length
        ret += sum(self.cycle[:n])
        return ret

def main():
    N, X, M = map(int, input().split())

    rs = RhoSequence(lambda x: x*x%M, X, M-1, 0)

    # print(rs.get_nth_value(N))
    print(rs.sum_until_n(N))

if __name__ == '__main__':
    main()

Measured memory_bytes: 13480
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	map<int, int> occs;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		++occs[a];
	}

	int min_removals = 0;
	for (auto it = occs.begin(); it != occs.end(); ++it) {
		if (it->second > it->first) {
			min_removals += (it->second - it->first);
		}
		else if (it->second < it->first) {
			min_removals += it->second;
		}
	}

	cout << min_removals << "\n";

	return 0;

}

Measured memory_bytes: 4736
import os
import sys

import numpy as np
from heapq import heappop, heappush


def solve(h, w, s, t, field):
    WARP = (-(w * 2 + 10), -(w * 2 + 9), -(w * 2 + 8), -(w * 2 + 7), -(w * 2 + 6),
            -(w + 6), -(w + 5), -(w + 3), -(w + 2),
            -2, 2,
            w + 2, w + 3, w + 5, w + 6,
            w * 2 + 6, w * 2 + 7, w * 2 + 8, w * 2 + 9, w * 2 + 10)
    WALK = (-(w + 4), -1, 1, w + 4)

    q = [(0, s)]
    visited = np.zeros((h + 4) * (w + 4), np.int8)
    queued = np.zeros((h + 4) * (w + 4), np.int8)
    queued[s] = 1
    while q:
        cost, v = heappop(q)
        if v == t:
            return cost
        if visited[v]:
            continue
        visited[v] = 1
        for d in WALK:
            u = v + d
            if field[u] or visited[u] or queued[u]:
                continue
            queued[u] = 1
            heappush(q, (cost, u))
        for d in WARP:
            u = v + d
            if field[u] or visited[u] or queued[u]:
                continue
            heappush(q, (cost + 1, u))

    return -1


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8,i8,i8,i8,i1[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8,i8,i8,i8,i1[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

h, w = map(int, sys.stdin.readline().split())
ch, cw = map(int, sys.stdin.readline().split())
dh, dw = map(int, sys.stdin.readline().split())
field = np.ones((h + 4) * (w + 4), dtype=np.int8)
for i in range(h):
    line = sys.stdin.readline().strip()
    field[(i + 2) * (w + 4) + 2:(i + 2) * (w + 4) + w + 2] = list(map('.#'.index, line))
s = (ch + 1) * (w + 4) + cw + 1
t = (dh + 1) * (w + 4) + dw + 1
ans = solve(h, w, s, t, field)
print(ans)


Measured memory_bytes: 30532
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int h, w;
   cin>>h>>w;
   vector<string> s(h);
   rep(i, h) cin>>s[i];

   int di[]={-1, 1, 0, 0};
   int dj[]={0, 0, -1, 1};

   int mita[20][20];

   int mx=0;
   rep(si, h) rep(sj, w){
      if(s[si][sj]=='#') continue;
      queue<P> q, nq;
      q.push(make_pair(si, sj)); 
      rep(i, h) rep(j, w) mita[i][j]=false;
      mita[si][sj]=true;
      int cnt=0;
      while(!q.empty()){  
         while(!q.empty()){
            P p=q.front(); q.pop();
            int ci=p.first, cj=p.second;
            rep(k, 4){
               int ni=ci+di[k], nj=cj+dj[k];
               if(0<=ni && ni<h && 0<=nj && nj<w) if(s[ni][nj]=='.') if(!mita[ni][nj]){
                  mita[ni][nj]=true;
                  nq.push(make_pair(ni, nj));
               }
            }
         }
         if(!nq.empty()) cnt++;
         swap(q, nq);
      }
      mx=max(mx, cnt);
   }

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


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

vector<int> min_cost_match(vector<vector<int>> a) {
	int n=a.size(),m=a[0].size();
	vector<int> left(n,-1), right(m,-1);
	vector<int> ofsleft(n,0), ofsright(m,0);
	auto cost=[&](int i,int j){ return a[i][j]+ofsleft[i]+ofsright[j];};

	rep(r,n){
		vector<bool> s(n,false),t(m,false);
		vector<int> trace(m,-1), edge(m,r);
		s[r]=true;

		int b=-1;
		while(1){
			int d=numeric_limits<int>::max();
			rep(j,m) if(!t[j]) d=min(d,cost(edge[j],j));
			rep(i,n) if(s[i]) ofsleft[i]-=d;
			rep(j,m) if(t[j]) ofsright[j]+=d;

			rep(j,m) if(!t[j]&&cost(edge[j],j)==0) b=j;
			trace[b]=edge[b];
			int c=right[b];
			if(c<0) break;

			s[c]=t[b]=true;
			rep(j,m) if(cost(c,j)<cost(edge[j],j)) edge[j]=c;
		}
		while(b>=0){
			int a=trace[b],nb=left[a];
			right[b]=a,left[a]=b,b=nb;
		}
	}
	return left;
}

int n;
int w[110][110],e[110][110];
string s[110];
bool op[110][110];

int row[110],col[110];

int main(void){
	cin >> n;
	rep(i,n)rep(j,n) cin >> w[i][j];
	rep(i,n)rep(j,n) cin >> e[i][j];
	rep(i,n) cin >> s[i];

	rep(i,n){
		row[i]=0,col[i]=0;
		rep(j,n) if(s[i][j]=='o') row[i]+=e[i][j];
		rep(j,n) if(s[j][i]=='o') col[i]+=e[j][i];
	}

	vector<vector<int>> cost(n,vector<int>(n,0));
	rep(i,n)rep(j,n){
		if(s[i][j]=='o')
			cost[i][j]=row[i]+col[j]-2*e[i][j];
		else
			cost[i][j]=row[i]+col[j]+2*w[i][j];
	}
	vector<int> match=min_cost_match(cost);
	rep(i,n) op[i][match[i]]=true;

	int mincost=0,cnt=0;
	rep(i,n)rep(j,n){
		if(s[i][j]=='.'&&op[i][j]==true) mincost+=w[i][j],cnt++;
		if(s[i][j]=='o'&&op[i][j]==false) mincost+=e[i][j],cnt++;
	}
	cout << mincost << endl;
	cout << cnt << endl;
	rep(i,n)rep(j,n){
		if(s[i][j]=='.'&&op[i][j]==true) printf("%d %d write\n",i+1,j+1);
		if(s[i][j]=='o'&&op[i][j]==false) printf("%d %d erase\n",i+1,j+1);
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int variavle = 1;
  
  for (int i = 0; i < N; i++) {
    if (variavle < K) {
      variavle *= 2;
    } else {
      variavle += K;
    }
  }
  
  cout << variavle << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
	int n;
	cin>>n;
	int m = 0;
	int cur = 0;
	rep(i,0,n){
		int t1, t2;
		cin>>t1>>t2;
		if(t1==t2) cur++;
		else cur = 0;
		m = max(cur, m); 
	}
	if(m>2){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(n,k) for(int i = (int)n;i<k;i++)
using Int =long long int;
using Graph =vector<vector<int>>;
Int cho(Int n){
    return (n-1)*n/2;
}

int main(){

    
    int N;
    cin>>N;
    vector<string>ans(N);
    Int sum=0;
    rep(0,N){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        ans.at(i)=s;
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<N;i++){
        string memo = ans[i];
        Int buffer =0;
        do{
            buffer++;
            i++;

        }while(memo==ans[i]);
        i--;
        if(buffer!=1) sum += cho(buffer);
    }
    cout<<sum<<endl;
}
    

Measured memory_bytes: 6412
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,Y;cin>>N>>Y;
  bool finished=false;
  for(int i=0;i<=N;i++){
  	for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
      	cout<<i<<" "<<j<<" "<<N-i-j<<endl;
        finished=true;
        break;
      }
    }
    if(finished) break;
    else if(i==N) cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> cnt(M, 0);
    for (int i = 0; i < N; i++) {
        int K; cin >> K;
        for (int i = 0; i < K; i++) {
            int a; cin >> a; a--;
            cnt[a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (cnt[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        try
        {
        Console.WriteLine((char)Enumerable.Range((int)'a', 26).First(x => !s.Contains((char)x)));
        }
        catch
        {
            Console.WriteLine("None");
        }
    }
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int tab[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n=s.size();
    int res=n;
    for(int i=1;i<n;i++)
		if(s[i]!=s[i-1]) res=min(res,max(i,n-i));
	cout << res;	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m;
	cin>>n>>m;
	int a[m];
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		n-=a[i];
	}
	if(n>-1)
	cout<<n<<endl;
	else
	cout<<"-1\n";
} 

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    int N,M;
    cin >> N >> M;
    dsu d(N);
    for (int i = 0; i < M; i++) {
        int A,B;
        cin >> A >> B;
        A--; B--;
        d.merge(A,B);
    }
    bool le[1000010];
    mem0(le);
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        int n = d.leader(i);
        if(le[n] == false){
            le[n] = true;
            cnt++;
        }
    }
    cout << cnt-1 << endl;
}

Measured memory_bytes: 4568
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define DUMP(x) cerr<<#x<<":="<<(x)<<endl
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<" "<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    int n,k;
    cin>>n>>k;
    ll ans=k;
    REP(i,n-1) {
        ans*=(k-1);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int n = 0;
	int m = 100000;
	
	scanf("%d", &n);
	
	for( ; n != 0; n--){
		m = (int)(m * 0.00105) * 1000;
		m += 1000;
	}
	printf("%d\n", m);
	
	return 0;
}

Measured memory_bytes: 0
def bubbleSort(a, n)
  flag = 1
  count = 0;
  while flag == 1 do
    flag = 0
    (n-1).step(1,-1){|j|
      if a[j] < a[j-1] then
        a[j], a[j-1] = a[j-1], a[j]
        flag = 1
        count += 1
      end
    }
  end
  puts a.join(" ")
  puts count
end

n = gets.to_i
a = gets.split.map(&:to_i)
bubbleSort(a,n)

Measured memory_bytes: 8736
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (x == 0 && y == 0)
				break;
			if (x < y) {
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);

			}
		}
	}

}


Measured memory_bytes: 35300
#include <stdio.h>
int main(void) {
  int n, a, b, pointa, pointb, i;
  while(scanf("%d",&n),n) {
    pointa = 0; pointb = 0;
  for(i = 0; i < n; i++ ) {
    scanf("%d%d",&a,&b);
    if(a < b) {
      pointb += a+b;
    } else if(a > b) {
      pointa += a+b;
    } else {
      pointa += a; pointb += b;
    }
  }
  printf("%d %d\n",pointa,pointb);
  }
  return(0);
}

Measured memory_bytes: 1028
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Point[] point = new Point[n];
        for (int i = 0; i < n; i++) {
            point[i] = new Point();
        }
        int[] index = new int[n - 1];
        
        // 自分に子を割り当てる
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            index[i] = q;   // 出力順を記憶する
            
            point[p].children.add(q);
        }
        
        // 自分の子を若い色から塗る
        point[0].color = 0;
        for (int i = 0; i < n; i++) {
            int nowColor = 1;
            int myColor = point[i].color;
            
            for (Integer child : point[i].children) {
                if (nowColor == myColor) {
                    nowColor++;
                }
                
                point[child].color = nowColor;
                nowColor++;
            }
        }
        
        // 必要な最小色数を出力
        int max = 0;
        for (Point p : point) {
            max = Math.max(max, p.color);
        }
        System.out.println(max);
        
        // 子の色を出力順に出力
        for (int i = 0; i < n - 1; i++) {
            System.out.println(point[index[i]].color);
        }
        
    }
    
    public static class Point {
        int color;
        List<Integer> children;
        
        Point() {
            this.children = new ArrayList<Integer>();
        }
    }
}


Measured memory_bytes: 99020
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A;

    int ans = 0;

    for(int i = 0; i<N; i++){
        int a;
        cin >> a;
        auto itr = upper_bound(A.begin(), A.end(), a-1);
        if(itr == A.begin()){
            A.insert(A.begin(), a);
            ans ++;
        }
        else{
            *(itr -1) = a;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7, A = 1e4+5;
string k;
int d, memo[A][105][2];
int dp(int ind, int sum, bool rem)
{
	if (ind == (int)k.size())
		return (sum ? 0 : 1);
	int &ans = memo[ind][sum][rem];
	if (~ans)
		return ans;
	ans = 0;
	for (int i = 0; i <= 9; i++)
	{
		int cur_ind = k[ind] - '0', cur_sum = (sum + i) % d;
		if (rem == 1)
			ans = (ans + dp(ind + 1, cur_sum, 1)) % mod;
		else
		{
			if (i > cur_ind)
				continue;
			ans = (ans + dp(ind + 1, cur_sum, (i == cur_ind ? 0 : 1))) % mod;
		}
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> k >> d;
	memset(memo, -1, sizeof memo);
	cout << (dp(0, 0, 0) - 1 + mod) % mod;
	return 0;
}


Measured memory_bytes: 9472
import sys


def solve():
    readline = sys.stdin.readline
    N = int(readline())
    ABC = (map(int, readline().split()) for _ in range(N))
    x, y, z = 0, 0, 0
    for a, b, c in ABC:
        x, y, z = a + max(y, z), b + max(x, z), c + max(x, y)

    return max(x, y, z)


if __name__ == "__main__":
    answer = solve()
    print(answer)

Measured memory_bytes: 42860
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

a, b = tuple(map(int, input().strip().split()))

if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Measured memory_bytes: 8972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int h1 = sc.NextInt();
        int m1 = sc.NextInt();
        int h2 = sc.NextInt();
        int m2 = sc.NextInt();
        int k = sc.NextInt();

        int m = (h2 * 60 + m2) - (h1 * 60 + m1);

        int answer = m - k;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, k;
ll a[100100];
ll sum[100100];
ll sum2[100100];

int main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (i != 0) {
			sum[i] = sum[i - 1] + a[i];
			sum2[i] = sum2[i - 1] + max((ll)0, a[i]);
		}
		else {
			sum[i] = a[i];
			sum2[i] = max((ll)0, a[i]);
		}
	}
	ll ans = -1e15;
	rep(i, n - k + 1) {
		ll num;
		if (i > 0) {
			num = max((ll)0, sum[k - 1 + i] - sum[i - 1])
				+ sum2[n - 1] - sum2[k - 1 + i] + sum2[i - 1];
		}
		else {
			num = max((ll)0, sum[k - 1 + i])
				+ sum2[n - 1] - sum2[k - 1 + i];
		}
		//cout << i << " " << num << endl;
		ans = max(ans, num);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
def bubbleSort(A, N):
    flag = 1
    cnt = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                cnt += 1
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
    print(*A)
    print(cnt)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    bubbleSort(A, N)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();

		System.out.println((int)((t + 0.5) / a) * b);
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>

int dp[100][100][4];

int main() {
	int w,h;
	while(scanf("%d %d",&w,&h),w||h) {
		memset(dp,0,sizeof(dp));
		dp[0][1][0]=dp[1][0][2]=1;
		for(int j=0;j<h;j++) {
			for(int i=0;i<w;i++) {
				dp[i][j][0]+=((j?dp[i][j-1][0]:0)+(j?dp[i][j-1][1]:0))%100000;
				dp[i][j][1]+=(j?dp[i][j-1][2]:0)%100000;
				dp[i][j][2]+=((i?dp[i-1][j][2]:0)+(i?dp[i-1][j][3]:0))%100000;
				dp[i][j][3]+=(i?dp[i-1][j][0]:0)%100000;
			}
		}
		int sum=0;
		for(int i=0;i<4;i++) sum+=dp[w-1][h-1][i];
		printf("%d\n",sum%100000);
	}
}

Measured memory_bytes: 1192
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t = 1; cin>>t; while(t--)
#define ain int n,k,i; cin>>n; int a[n]; for(i=0;i<n;i++) cin>>a[i]
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define I insert
#define pb push_back

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
inline ll add(ll a, ll b) { return (mod + a + b) % mod;}
inline ll sub(ll a, ll b) {return (a - b + mod) % mod;}
inline ll mul(ll a, ll b) {return (1ll * a * b) % mod;}
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) { if(y & 1) res = (res * x) % mod; y = y >> 1;x = (x * x) % mod;}return res;}
ll inv(ll x) {
    return fastpow(x, mod - 2);
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin >> n;
    string S = "";
    while(n)
    {
        
        ll dig = n % 26;
        if(dig == 0)
            dig = 26;
        S += (char)(96 + dig);
         
         n -= dig;
         n /= 26;
         
        
    }
    
    reverse(all(S));
    cout << S;
    
    
    
    
    
    
    
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
    int a,b,x;
    scanf("%d %d %d",&x,&a,&b);
    if(a-b>=0){
        printf("delicious\n");
    }else if((b-a)<=x){
        printf("safe\n");
    }else{
        printf("dangerous\n");
    }
    return 0;
}




Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;
bool dame[10];
bool sol(int n){
  while(n>0){
    if(dame[n%10]) return false;
    n/=10;
  }
  return true;
}
int main(void){
  int n,k,x;
  cin>>n>>k;
  for(int i=0;i<k;i++){
    cin>>x;
    dame[x]=true;
  }
  for(int i=n;i<=99999;i++){
    if(sol(i)){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<"warota"<<endl;
  return 0;
}



Measured memory_bytes: 256
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        a: isize,
        b: isize,
    );
    let diff = a - b*2;
    if diff < 0 {
        println!("0");
    } else {
        println!("{}", diff);
        
    }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		for (int i = 0; i < N; i++) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}
		
		double ans = 0;
		int[][] e = new int[M][];
		for (int j = 0; j < M; j++) {
			int p = in.nextInt();
			int q = in.nextInt();
			int dx = x[p - 1] - x[q - 1];
			int dy = y[p - 1] - y[q - 1];
			int d2 = dx * dx + dy * dy;
			e[j] = new int[]{p - 1, q - 1, d2};
			ans += Math.sqrt(d2);
		}
		
		Comparator<int[]> cmp = new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				return b[2] - a[2];
			}
		};
		Arrays.sort(e, cmp);
		
		DisjointSetForest dsf = new DisjointSetForest(N);
		for (int j = 0; j < M; j++) {
			int v = e[j][0];
			int w = e[j][1];
			int d2 = e[j][2];
			if (dsf.find(v) != dsf.find(w)) {
				dsf.union(v, w);
				ans -= Math.sqrt(d2);
			}
		}
		System.out.println(ans);
	}
}

class DisjointSetForest {
	int[] parent;
	int[] rank;
	
	DisjointSetForest(int n) {
		parent = new int[n];
		Arrays.fill(parent, -1);
		rank = new int[n];
	}
	
	int find(int x) {
		if (parent[x] == -1) {
			return x;
		} else {
			return parent[x] = find(parent[x]);
		}
	}
	
	void union(int x, int y) {
		x = find(x);
		y = find(y);
		if (x != y) {
			if (rank[x] < rank[y]) {
				parent[x] = y;
			} else {
				parent[y] = x;
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}
	}
}

Measured memory_bytes: 70008
from collections import deque
counter = 0
todo = deque(range(1, 10))
ans = []
while counter < 10**5 + 500:
    seed = str(todo.popleft())
    ans.append(int(seed))
    counter += 1
    seed_last = seed[-1]
    for i in range(max(0, int(seed_last)-1), min(10, int(seed_last)+2)):
        todo.append(seed + str(i))

K = int(input())
print(ans[K-1])

Measured memory_bytes: 20980
#include<stdio.h>
int main(void)
{
    int A,B;
    int S1=0,S2=0,S3=0;
  
    scanf("%d%d",&A,&B);
    S1=A+B;
    S2=A-B;
    S3=A*B;
  if((S1>=S2)&&(S2>S3)) printf("%d\n",S1);
  else if((S1>=S3)&&(S3>S2)) printf("%d\n",S1);
  else if((S2>=S1)&&(S1>S3)) printf("%d\n",S2);
  else if((S2>=S3)&&(S3>S1)) printf("%d\n",S2);
  else if((S3>=S1)&&(S1>S2)) printf("%d\n",S3);
  else if((S3>=S2)&&(S2>S1)) printf("%d\n",S3);
  else printf("%d\n",S1);
  
  return 0;
}


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

#define INF (1<<30)-1
#define LINF (1LL<<62)-1LL
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

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

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=INF,sum=0;

    int d,g;
    cin>>d>>g;
    vector<P> pr(d);

    rep(i,d){
        int pi,ci;
        cin>>pi>>ci;
        pr[i] = P(pi,ci);
    }



    rep(i , (1<<d)){
        vector<int> cb(d,0);
        int cur = i;
        
        int acCount = 0;
        int pointSum = 0;

        rep(j,d){
            cb[j] = cur%2;
            cur /= 2;
        }

        rep(j,d){
            //cout<<cb[j]<<",";

            if(cb[j]==1){
                acCount += pr[j].fi;
                pointSum += 100*(j+1)*pr[j].fi;
                pointSum += pr[j].se;
            }
        }

        rep(j,d){
            int p = d-1-j;
            if(pointSum >= g)break;
            if(cb[p]==0){
                int rem = g - pointSum;
                int task = (rem+(100*(p+1))-1)/(100*(p+1));

                int slv = min(pr[p].fi , task);

                acCount += slv;
                pointSum += (p+1)*100*slv;

            }
        }

        //db(acCount);ln;

        if(pointSum >= g){
            chmin(ans,acCount);
        }
    }



    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val Array(n, k) = readLine().split(" ").map(_.toInt)

    // i 連続でコインが2倍になって行くと、目 * point(i) 点
    val point = (0 to 17).map(i => Math.pow(1/2.0, i))

    // 2の何乗をかければK以上になるか？
    // 必ず勝てるか　log 2 x = Math.log(x) - Math.log(2)
    val p = (1 to Math.min(n, k-1)).foldLeft(0.0) { (b, i) =>
      val x = k / i.toDouble
      val nx = Math.ceil(Math.log(x) / Math.log(2)).toInt
      b + point(nx)
    }
    // k以上の目が出る場合には常に勝利する
    // k以上の目が常に出ない場合には、
    if (n >= k) {
      println((p + (n - k + 1))/n)
    } else {
      println(p / n)
    }
  }

  // 勝つためには連続で表が出る必要がある。
  // サイコロの出る可能性がある全ての目に対して、確率を足し合わせたもの
  // サイコロのある目の出る確率は、1/可能性、*出た目を何倍すればいいか

}

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

n,k = inpl()
h = inpl()
res = 0
for i in h:
    if i >= k:
        res += 1
print(res)


Measured memory_bytes: 51948
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	k := iScan()
	n := len(s)
	x := make(map[string]struct{})
	for i := 0; i < n; i++ {
		for j := i + 1; j <= smaller(i+5, n); j++ {
			x[s[i:j]] = struct{}{}
		}
	}
	y := make([]string, 0, len(x))
	for k, _ := range x {
		y = append(y, k)
	}
	sort.Strings(y)
	fmt.Println(y[k-1])
}


Measured memory_bytes: 3428
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
constexpr int mod=998244353;
int dp[3001][3001];
signed main(){
    int n,s,a[3000];
    cin>>n>>s;
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=s;j++){
            dp[i][j]=dp[i-1][j]*2%mod;
            if(j>=a[i-1])
                (dp[i][j]+=dp[i-1][j-a[i-1]])%=mod;
        }
    }
    cout<<dp[n][s]<<endl;
}

Measured memory_bytes: 73996
#include <iostream>

using namespace std;

int main() {
	bool spade[13] = { false },
		 heart[13] = { false }, 
		 club[13] = { false },
		 diamond[13] = { false };
	char mark;
	int having, n;

	cin >> having;

	for(int i = 0;i < having;i++) {
		cin >> mark >> n;

		switch(mark) {
			case 'S':
				spade[n - 1] = true;
				break;
			case 'H':
				heart[n - 1] = true;
				break;
			case 'C':
				club[n - 1] = true;
				break;
			case 'D':
				diamond[n - 1] = true;
				break;
		}
	}

	for(int i = 0;i < 13;i++) {
		if(!spade[i])
			cout << "S " << i + 1 << endl;
	}

	for(int i = 0;i < 13;i++) {
		if(!heart[i])
			cout << "H " << i + 1 << endl;
	}

	for(int i = 0;i < 13;i++) {
		if(!club[i])
			cout << "C " << i + 1 << endl;
	}

	for(int i = 0;i < 13;i++) {
		if(!diamond[i])
			cout << "D " << i + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3084
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		int cnt=0;
		int max=0;

		for(int s=0;s<n;s++){
			for(int t=0;t<n;t++){
				if(s!=t){
					int p = x[t]-x[s];
					int q = y[t]-y[s];
					for(int u=0;u<n;u++){
						for(int v=0;v<n;v++){
							if((x[v]-x[u]==p)&&(y[v]-y[u]==q))cnt++;
						}
					}
					max = Math.max(max,cnt);
					cnt=0;
				}
			}
		}

		// 出力
		System.out.println(n-max);
	}
}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int town[N][2];
int n;

double calDist(int x, int y) {
	return sqrt((town[x][0] - town[y][0]) * (town[x][0] - town[y][0]) * 1.0 + (town[x][1] - town[y][1]) * (town[x][1] - town[y][1])); 
}

int main() {
	cin>>n;
  	int ret = 1;
  	for(int i=1;i<n;i++)
      ret *= i;
  	
  	for(int i=0;i<n;i++) {
    	cin>>town[i][0]>>town[i][1];
    }
  
  	double sum = 0.0;
  	for(int i=0;i<n-1;i++) {
      for(int j=i+1;j<n;j++) {
          sum += (2.0 * ret * calDist(i, j));
      }
    }
	// cout<<sum<<endl;
    sum = sum / (ret * n * 1.0);
  	cout<<fixed<<sum<<endl;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    string S; cin>>S;
    int N = S.size();
    int sum = 0;
    int res = 0;
    rep(i,N){
        if(S[i]=='g'){
            if(sum>0){
                res++;
                sum--;
            }else{
                sum++;
            }
        }else{
            if(sum>0){
                sum--;
            }else{
                res--;
                sum++;
            }
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2 << endl;
    }
    else 
    {
        cout << (a + b) / 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = gets.chomp
hash =  ('a'..'z').map{|s| [s, false]}.to_h
hash.keys.each do |k, v|
    hash[k] = !!S.match(k)
end
c = hash.keep_if{|k, v| !v}.keys.sort.first
puts c ? c : 'None'

Measured memory_bytes: 2044
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i == 10) {
      i = 99;
      continue;
    } else if (i == 1000) {
      i = 9999;
      continue;
    } else if (i == 100000) {
      continue;
    }
    ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	int i;
	int f = 1;

	int n;
	n = s.length();
	for (i = 0; i < n; i++)
	{
		if (s.at(i) != s.at(s.length() - 1 - i))
			f = 0;
	}
	if (f == 1)
	{
		for (i = 0; i < (n - 1) / 2; i++)
		{
			if (s.at(i) != s.at((n - 1) / 2 - 1 - i))
				f = 0;
		}
	}
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3552
def d_binomial_coefficients(N, A):
    if N == 2:
        return '{} {}'.format(max(A), min(A))
    import numpy
    max_a = max(A)
    tmp = max_a / 2
    idx = numpy.abs(numpy.asarray(A) - tmp).argmin()
    ans = '{} {}'.format(max_a, A[idx])
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(d_binomial_coefficients(N, A))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

static const double pi = 3.141592653589793;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(10)<<fixed;
  double a, b, x;
  cin>>a>>b>>x;
  // if(a*a*b==x){
  //   cout<<0<<'\n';
  //   return 0;
  // }
  if(a*a*b/2<x){
    double lb=0, ub=90;
    while(ub-lb>1e-9){
       double mid=(lb+ub)/2;
      if(a*a*b-0.5*a*a/tan(pi/180*mid)*a>x){
        ub=mid;
      }
      else{
        lb=mid;
      }
    }
    cout<<90-ub<<'\n';
  }
  else{
    double lb=0, ub=90;
    while(ub-lb>1e-9){
      double mid=(lb+ub)/2;
      if(0.5*b*b*tan(pi/180*mid)*a>x){
        ub=mid;
      }
      else{
        lb=mid;
      }
    }
    cout<<90-ub<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int h, w, n, a, x, y, dx = 1, ans[N][N];
int main()
{
	int i, j;
	cin >> h >> w >> n;
	for (i = j = 0; i < h * w; i++, a--) {
		if (a == 0) scanf("%d", &a), j++;
		ans[y][x] = j;
		x += dx;
		if (x < 0 || x == w) dx = -dx, x += dx, y++;
	}
	for (i = 0; i < h; i++, puts("")) for (j = 0; j < w; j++) printf("%d ", ans[i][j]);
    return 0;
}

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

int main(){
    int S, h, m, s;
    
    cin >> S;
    
    h = S / 60 / 60;
    m = (S - h * 60 * 60) / 60;
    s = S - h * 60 * 60 - m * 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3096