akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, M;
int P[1010];
VI enum1, enum2;


void makeEnum(){
	enum1.pb(0);
	rep(i, 0, N) enum1.pb(P[i]);
	rep(i, 0, N)
		rep(j, 0, N) enum1.pb(P[i]+P[j]);
	sort(ALL(enum1));
	UNIQUE(enum1);
	enum2 = enum1;
}


void clear(){
	enum1.clear();
	enum2.clear();
}


int solve(){
	int ans = 0;
	for(int x : enum1){
		if(x > M) continue;
		auto it = ub(ALL(enum2), M-x);
		if(it == enum2.begin()) continue;
		ans = max(ans, *(it-1)+x);
	}
	return ans;
}


signed main(){
	while(cin >> N >> M, N || M){
		rep(i, 0, N) cin >> P[i];
		
		makeEnum();
		
		cout << solve() << endl;
		
		clear();
	}
	
	return 0;
}



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

int main (){

  string a, b;
  cin >> a >> b;
  if((a=="H"&&b=="H")||(a=="D"&&b=="D")){
      cout << "H" << endl;
  }
  else {
      cout << "D" << endl;
  }
}

Measured memory_bytes: 256
MOD = 1_000_000_007

def power(n, k)
  x = 1
  r = n
  while k > 0
    x *= r if k & 1 == 1
    r *= r
    x %= MOD
    r %= MOD
    k >>= 1
  end
  x
end

p power(*gets.split.map(&:to_i))


Measured memory_bytes: 6864
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let _n:i64 = read();
    let a:Vec<i64> = read_vec();
    let mut min = a[0];
    let mut max = a[0];
    let mut sum = 0;
    for x in a {
        if min > x {
            min = x;
        }
        if max < x {
            max = x;
        }
        sum += x;
    }
    println!("{} {} {}", min, max, sum);
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    set<int> s;
    int a;
    rep(i,n){
        cin>>a;
        s.insert(a);
    }
    int tmp=n-s.size();
    if(tmp==0)cout<<n<<endl;
    else if(tmp%2==0)cout<<s.size()<<endl;
    else cout<<s.size()-1<<endl;
}

Measured memory_bytes: 4992
#include  <iostream>

using namespace std;

int a[4];
char op[3];

bool rec(int i, int sum)
{
	if (i == 3)  return sum == 7;
	
	if (rec(i + 1, sum + a[i + 1])) {
		op[i] = '+';
		return true;
	}
	
	if (rec(i + 1, sum - a[i + 1])) {
		op[i] = '-';
		return true;
	}
	return false;
}

int main()
{
	char c[5];
	cin >> c;
	for (int i = 0; i < 4; i++)  a[i] = c[i] - '0';
	if (rec(0, a[0])) {
		cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
  int N=0;
  int d = 3;
  cin >> N;
  int group;
  group = N / d;
  // if((N%d != 0)&&(N>=d)) group++;
  cout << group << endl;

  return 0;
}


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

int i, in, bt;
int main(){
	string S;
	cin >> S;

	in = atoi(S.c_str());
	in = in / 100;

	bt = atoi(S.c_str());
	bt %= 100;

	if ((in > 12 || in == 0) && (bt > 12 || bt == 0)) cout << "NA" << endl;
	else if ((in > 0 && in <=12) && (bt > 0 && bt <= 12)) cout << "AMBIGUOUS" << endl;
	else if ((in > 12 || in == 0) && (bt > 0 && bt <= 12)) cout << "YYMM" << endl;
	else cout << "MMYY" << endl;
	return 0;
}



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

typedef long long ll;
typedef long double ld;
const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll  INF = 1e18;
const ld  PI = acos((ld) -1);
template<class T> inline void array_input(T a[], size_t n){for(size_t i = 0; i < n; i++)cin >> a[i];}
/*
template<class T>
inline void array_init(T a[], T val){
    for(size_t i )
}
*/
long long binExp(long long a, long long b, long long mod){
    long long res = 1;
    while(b > 0){
        if(b % 2) res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}

//#define FILE
int main(){
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // 0

    int n;
    cin >> n;
    int a[n];
    array_input(a, n);

    sort(a, a+n);
    int ans = 0;
    bool flag = true;

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            flag = true;
            for(int k = j+1;flag && k < n; k++){
                if(a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
                if(a[i]+a[j] > a[k]) ans++;
                else flag = false;
            }

        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3620
public class Main {

	public void run(java.util.Scanner sc, java.io.PrintStream out) {
		final int n = sc.nextInt();
		final double[] r = new double[n];
		for (int i = 0; i < n; ++i)
			r[i] = sc.nextInt();
		final double[] c = new double[n];
		c[0] = r[0];
		for (int i = 1; i < n; ++i) {
			c[i] = r[i];
			for (int j = 0; j < i; ++j) {
				c[i] = Math.max(c[i], c[j] + Math.sqrt(Math.pow(r[j] + r[i], 2) - Math.pow(r[j] - r[i], 2)));
			}
		}
		double res = 0;
		for (int i = 0; i < n; ++i)
			res = Math.max(res, c[i] + r[i]);
		System.out.printf("%.8f\n", res);
	}
	
	public static void main(String[] args) {
		(new Main()).run(new java.util.Scanner(System.in), System.out);
	}

}

Measured memory_bytes: 28568
def 解():
    iN,iK = [int(_) for _ in input().split()]
    dA = {}
    def addD(d,a):
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
    for a in [int(_) for _ in input().split()]:
        addD(dA,a)
    aV = dA.values()
    print(sum(sorted(aV)[0:len(aV)-iK]))
解()


Measured memory_bytes: 32260
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const int mod = 1000000007;
const ll infll = (1ll<<60);
using namespace std;

ll dp[2500000];

int main(){
	int n; cin >> n;
	int a[n][n];
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			cin >> a[i][j];
		}
	}
	int bound = (1<<(n));
	dp[0] = 1;
	for( int k = 0; k < bound; ++k ){
		for( int j = 0; j < n; ++j ){
			bitset<30> cond = k;
			if( a[cond.count()][j] == 1 && !(cond.test(j)) ){
				dp[cond.set(j).to_ullong()] += dp[cond.to_ullong()];
				dp[cond.set(j).to_ullong()] %= mod;
			}
		}
	}
	cout << dp[bound-1] << endl;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

 	ll x,a,b;
 	cin >> x >> a >> b;

 	if(b-a<=0)
 		cout << "delicious\n";
 	else if(b-a<=x)
 		cout << "safe\n";
 	else
 		cout << "dangerous\n";
 	
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re register
#define SIZE 10005
#define LL long long 
#define MOD 1000000007
using namespace std;
string k;
int d;
int maxn[SIZE],cnt;
LL dp[SIZE][105];
inline LL dfs(int pos,int sta,bool lim)
{
	if(pos>cnt)
		return sta==0?1:0;
	if(!lim && dp[pos][sta]!=-1)
		return dp[pos][sta];
	int up=lim?maxn[pos]:9;
	LL ret=0;
	for(re int i=0;i<=up;++i)
		ret=(ret+dfs(pos+1,(sta+i)%d,lim&&(i==maxn[pos])))%MOD;
	if(!lim)
		dp[pos][sta]=ret;
	return ret;
}
inline LL work()
{
	memset(dp,-1,sizeof(dp));
	cnt=k.size()-1;
	for(re int i=0;i<=cnt;++i)
		maxn[i]=k[i]-'0'; 
	return dfs(0,0,1);
}
int main()
{
	cin>>k;
	cin>>d;
	LL ans=(work()-1+MOD)%MOD;
	printf("%lld\n",ans);
	return 0;
} 
//3373

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

int main(){
    int64_t A;
    string B;
    cin >> A >> B;
    string instB = B.replace(B.find("."), 1, "");
    int64_t intB = atoi(instB.c_str()); 
    
    int64_t C = A * intB / 100;
    cout << C << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
///https://www.youtube.com/watch?v=-tJYN-eG1zk&list=RD-tJYN-eG1zk&start_radio=1
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue<int>
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
const int MXX = 1e5 + 5;

int a[MXX];
int main()
{

    FAST_IO;
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    return 0;
}




Measured memory_bytes: 256
map{/ /,push@
$`,$' for<>;map$q[$_]+=$q[$N]/@$N,@{$N=$_}}++$q[1]..<>;while(--$N){$s=$~=0;$s+=$_,$~=$_>$~?$_:$~for@e[@$N];$e[$N]=1+$s/@$N;$a<($t=$q[$N]*=$#$N&&($s-$~)/$#$N-$s/@$N)or$a=$t}print"@e"+$a

Measured memory_bytes: 42368
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> x(n, vector<int>(3));
  rep(i,n) cin >> x[i][0] >> x[i][1] >> x[i][2];
  vector<vector<ll>> dp(n, vector<ll>(3));
  dp[0][0]=x[0][0];
  dp[0][1]=x[0][1];
  dp[0][2]=x[0][2];
  for(int i=1; i<n; i++){
    rep(j,3){
      rep(k,3){
        if(j==k)
          continue;
        chmax(dp[i][k],dp[i-1][j]+x[i][k]);
      }
    }
  }
  ll res=0;
  rep(i,3)
    chmax(res, dp[n-1][i]);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 11136
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vi A(N), B(N); F0R(i, N) cin >> A[i] >> B[i];
    sort(all(A));
    sort(all(B));
    ll X, Y; 
    if (N % 2 == 1) {
        X = A[N/2];
        Y = B[N/2];
    } else {
        X = A[N/2 - 1] + A[N/2];
        Y = B[N/2 - 1] + B[N/2];
    }
 
    cout << Y-X+1 << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string S, T;
    cin >> S >> T;
    int ans = 0;
    REP(i,S.length()){
        if(S[i] != T[i]) ans++;;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int> > V;
int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
V mp(4,vector<int>(4));

struct dat{int x,y,dir,cost;};
void drop(int x,int y){
  int D[4][4];
  memset(D,-1,sizeof(D));
  queue<dat> Q;
  mp[y][x] = 0;
  for(int i=0;i<4;i++)Q.push((dat){x+dx[i],y+dy[i],i,1});
  
  while(!Q.empty()){
    dat t = Q.front();Q.pop();
    x = t.x, y = t.y;
    int I = t.dir, cost = t.cost;
    if(x<0||y<0||x>=4||y>=4)continue;  
    if(!mp[y][x]||(mp[y][x]>=5&&cost!=D[y][x]))
      Q.push((dat){x+dx[I],y+dy[I],I,cost+1});
    else if(++mp[y][x]==5){
      D[y][x] = cost;
      for(int i=0;i<4;i++)Q.push((dat){x+dx[i],y+dy[i],i,cost+1});
    }
  }
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)if(mp[i][j]>=5) mp[i][j]=0;
}

bool check(){
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)if(mp[i][j]) return 0;
  return 1;
}

map<V,int> mem;
int dfs(int cnt=0){
  if(check()) return 0;
  if(cnt>=5) return 1e9;
  if(mem.count(mp)) return mem[mp];
  
  int res=1e9;
  for(int y=0;y<4;y++)
    for(int x=0;x<4;x++){
      if(mp[y][x]==0)continue;
      V tmp = mp;
      if(++mp[y][x]==5)drop(x,y);
      res=min(res,1+dfs(cnt+1));
      mp = tmp;
    }
  return mem[mp] = res;
}

int main(){
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)cin>>mp[i][j];
  cout<<(dfs()>5? -1:dfs())<<endl;
  return 0;
}

Measured memory_bytes: 4676
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll m, d; cin >> m >> d;
    
    // 22日以降が対象
    // 1の桁と10の桁の積が月だったらOK
    // 制約が小さいので愚直にシミュレーションする。

    ll ans = 0;
    for(ll i=1; i<=m; i++){
        for(ll j=22; j<=d; j++){
            ll m10 = j/10;
            ll m1 = j%10;
            if(m1 >= 2 && m10 >= 2 && m1*m10 == i) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
 
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
 
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main(void){
    int H,W;
    cin>>H>>W;
    int h,w;
    cin>>h>>w;
    int ans = H*W - h*W - w*H + h*w;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = getLine >>= print . solve . map read . words
solve :: [Int] -> Int
solve (a:b:_) = lcm a b

Measured memory_bytes: 508
local k, n = io.read("*n", "*n")
local t = {}
for i = 1, n do
  local tmp = {}
  tmp.cnt = io.read("*n")
  tmp.idx = i
  t[i] = tmp
end
table.sort(t, function(a, b) return a.cnt < b.cnt end)
local vanish = 0
local lastate = 0
while vanish < n - 1 do
  local tgt = n
  if lastate == t[n].idx then
    tgt = n - 1
  end
  t[tgt].cnt = t[tgt].cnt - 1
  if t[tgt].cnt == 0 then vanish = vanish + 1 end
  table.sort(t, function(a, b) return a.cnt < b.cnt end)
  lastate = t[tgt].idx
end
print(t[n].cnt - 1)


Measured memory_bytes: 384
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(),
            Q = sc.nextInt();
        String S = sc.next();
        int[] l = new int[Q],
              r = new int[Q];
        for(int i = 0; i < Q; i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        char[] letter = S.toCharArray();
        int[] ac = new int[N+1];
        ac[0] = 0;
        for(int i = 1; i < N; i++){
            ac[i] = ac[i-1];
            if(letter[i-1] == 'A'){
                if(letter[i] == 'C'){
                    ac[i]++;
                }
            }
        }
        for(int i = 0; i < Q; i++){
            System.out.println(ac[r[i]-1] - ac[l[i]-1]);
        }        
    }
}

Measured memory_bytes: 83096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int[] a = new int[n];
        int ecnt = 0;
        for (int i = 0; i < n; i++) {
            char tmp = s.charAt(i);
            if (tmp == 'E') {
                a[i] = 1;
                ecnt++;
            } else {
                a[i] = 0;
            }
        }
        int ans = ecnt;
        if (ans == n || ans == 0) {
            System.out.println(0);
            return;
        }
        int wcnt = 0;
        for (int i = 1; i < n; i++) {
            if (a[i - 1] == 1) {
                ecnt--;
            } else {
                wcnt++;
            }
            if (ans > ecnt + wcnt - a[i]) {
                ans = ecnt + wcnt - a[i];
            }
        }
        System.out.println(ans);

    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	multiset<int64_t> st;
	for (auto &a : as)
	{
		st.insert(a);
	}
	sort(as.begin(), as.end());
	reverse(as.begin(), as.end());
	int64_t ans = 0;
	for (auto &a : as)
	{
		if (st.find(a) != st.end())
		{
			st.erase(st.find(a));
			int64_t x = (1LL << (32 - __builtin_clz(a))) - a;
			auto itr = st.find(x);
			if (itr != st.end())
			{
				st.erase(itr);
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0]);
  const LineS = input[1].split(" ");
  const line = [];

  LineS.forEach(l => {
    line.push(parseInt(l));
  });

  function compare(a, b) {
    return a-b;
  }
  line.sort(compare);

  let answer = 0;

  for (let a = 0; a < line.length - 2; a++) {
    for (let b = a; b < line.length - 1; b++) {
      for (let c = b; c < line.length; c++) {
        if (line[a] === line[b] || line[b] === line[c]) {
          continue;
        }
        if (line[a] + line[b] > line[c]) {
          answer++;
        }
      }
    }
  }

  console.log(answer);

}
// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int r, g, b, n;
    cin >> r;
    cin >> g; 
    cin >> b;
    cin >> n;
    
    int rn, gn, bn;
    int count = 0;
    for(int i = 0; i * r <= n; i++){
        for(int j = 0; j * g <= (n-r*i); j++){
            if ((n-r*i-g*j) % b == 0){
                count ++;
            }
        }
    }
    
    cout << count;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>

#define INF 5000000

using namespace std;

int min(int n, int*);

int main(void) {
	int N, M, X;
	int* C;
	int** A;

	cin >> N >> M >> X;
	C = new int[N];
	A = new int* [N];
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		A[i] = new int[M];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	int output = INF;
	stack<string> Stack;
	Stack.push("0");
	Stack.push("1");

	while (!Stack.empty()) {
		string temp = Stack.top();
		Stack.pop();

		if (temp.length() == N) {
			int* skills = new int[M];
			int price = 0;
			for (int i = 0; i < M; i++) skills[i] = 0;

			for (int i = 0; i < N; i++) {
				for (int j = 0; j < M; j++)
					skills[j] += (temp[i] - '0') * A[i][j];
				price += (temp[i] - '0') * C[i];
			}

			if (min(M, skills) >= X)
				if (price < output) output = price;
		}
		else {
			Stack.push(temp + "0");
			Stack.push(temp + "1");
		}
	}

	if (output == INF) cout << -1 << endl;
	else cout << output << endl;

	return 0;
}

int min(int n, int* arr) {
	int m = INF;
	for (int i = 0; i < n; i++) {
		if (arr[i] < m) m = arr[i];
	}
	return m;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> x(N);
  for (ll i = 0; i < N; ++i) {
    cin >> x.at(i);
  }
  ll zero = lower_bound(x.begin(), x.end(), 0) - x.begin();
  // cout << x.at(zero) << endl;
  ll ans;
  if (zero + K - 1 < N) {
    ans = x.at(zero + K - 1);
  }
  if (zero - K >= 0) {
    ans = min(ans, abs(x.at(zero - K)));
  }
  for (ll i = 0; i < N; ++i) {
    if (i == zero) {
      break;
    }
    if (i + K < zero) {
      continue;;
    }
    if (i + K > N) {
      break;
    }
    if (x.at(i) * x.at(i + K - 1) > 0) {
      continue;
    }
    // cout << x.at(i + K - 1) << ' ' <<  x.at(i) << endl;
    ans = min(ans, x.at(i + K - 1) - x.at(i) * 2);
    ans = min(ans, x.at(i + K - 1) * 2 - x.at(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){

	int i,hill[10];
	int top[3]={0,0,0};


	for(i=0;i<10;i++){
		scanf("%d",&hill[i]);

		if(top[0]<=hill[i]){
			top[2] = top[1];
			top[1] = top[0];
			top[0] = hill[i];

		}else if(top[1]<=hill[i]){
			top[2] = top[1];
			top[1] = hill[i];

		}else if(top[2]<=hill[i]){
			top[2] = hill[i];
		}
	}
	
	printf("%d\n%d\n%d\n",top[0],top[1],top[2]);

	return 0;
}

Measured memory_bytes: 600
k, a, b = (int(i) for i in input().split())
ans = 0
if a+1>=b or k-a+1<2:
    ans = 1+k
else:
    left = (k-a+1)//2
    ans = left*(b-a) + a
    if (k-a+1)%2==1:
        ans += 1
print(ans)

Measured memory_bytes: 3060
var st,st1:string;
        yes:boolean;
        i:longint;
    begin
      readln(st);
      readln(st1);
      yes:=true;
      for i:=1 to length(st) do
        if st[i]<>st1[3-i+1]
        then yes:=false;
      if yes
      then writeln('YES')
      else writeln('NO');
    end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x, y;
    for (size_t i = 0; i < N; i++) {
        int p;
        cin >> p;
        x.push_back(p);
    }
    x.push_back(X);
    for (size_t i = 0; i < M; i++) {
        int p;
        cin >> p;
        y.push_back(p);
    }
    y.push_back(Y);
 
    int x_max = *max_element(x.begin(), x.end());
    int y_min = *min_element(y.begin(), y.end());
 
    if( x_max < y_min ) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb emplace_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
const int mod1 = 1000000007;
const int mod2 = 998244353;

int main()
{
	optimize

	int x;
	cin>>x;

	if(x >= 30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string ans="Three";
  for (int i=0; i<N; i++){
    string S;
    cin >> S;
    if (S=="Y"){
      ans="Four";
      break;
    }
  }
  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 all(x) x.begin(),x.end()
typedef long long ll;

int n;  
string s;

int main() {
  cin >> s;
  ll ans=0;
  for(int bit=0;bit<(1<<(int)s.size()-1);bit++){
    ll t=s[0]-'0';
    for(int i=0;i<(int)s.size()-1;i++){
      if(bit&(1<<i)){
        ans+=t; 
        t=s[i+1]-'0';
      }else{
        t*=10;
        t+=s[i+1]-'0';
      }
    }
    ans+=t;
  }
  cout << ans << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    rep(i, m){
        int s, c;
        cin >> s >> c;
        s--;
        if(n!=1&&s==0&&c==0){
            cout << -1 << endl;
            return 0;
        }
        if(a[s]!=c&&a[s]!=-1){
            cout << -1 << endl;
            return 0;
        }
        a[s] = c;
    }
    rep(i, n){
        if(a[i]==-1){
            if(n!=1&&i==0){
                a[i]=1; ///先頭の数字が設定されていなく桁数が１出ないときに最小の数字
            }
            else{
                a[i]=0;
            }
        }
        
    }
    int ans = 0;
    rep(i, n){
        ans += a[i]*pow(10, n-1-i);
    }

    cout << ans << endl;

}

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

int main() {
  int n;
  cin >> n;
  map<int, int> d;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    d.insert(make_pair(tmp, 1));
  }
  cout << d.size() << endl;
}

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

constexpr int MAX_N = 1e5;
int s[MAX_N+1];

int main() {

  // エラトステネスのふるい
  bitset<MAX_N + 1> isPrime;
  for (int i{2}; i <= MAX_N; ++i)
    isPrime.set(i);
  for (int i{2}; i <= MAX_N; ++i) {
    if (isPrime[i]) {
      for (int j{i * 2}; j <= MAX_N; j += i) {
        isPrime.reset(j);
      }
    }
  }

  // 累積和
//  vector<int> s(MAX_N + 1, 0);
  for (int i{1}; i <= MAX_N; ++i) {
    s[i] = s[i-1] + (isPrime[i] && isPrime[(i+1)/2]);
  }

  int Q; cin >> Q;
  for (int i{}; i < Q; ++i) {
    int l, r; cin >> l >> r;
    cout << s[r] - s[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = [int(i) for i in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
tmp =gcd_list(A)
for i in range(100):
    if tmp == 2**i:
        print(i)
        break

Measured memory_bytes: 5076
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int n;
    cin >> n;
    cout << db(n - n / 2) / db(n) << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int a,b,c;
  cin>>a>>b>>c;
  if(a!=b && b!=c && a!= c) cout<<3;
  else if(a!=b || b!=c ||a!=c) cout<<2;
  else cout<<1;
  cout<<endl;
  return 0;
}

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

using namespace std;

map<map<char, int>, int> pairs;

int main() {
    int n;
    string str;

    cin >> n;

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

        map<char, int> m;
        for (char c : str) {
            m[c]++;
        }

        pairs[m]++;
    }

    long long result = 0;

    for (auto &p : pairs) {

        for (int i = 1; i < p.second; i++) {
            result += i;
        }

    }

    cout << result << endl;
}

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

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    int a, b;

	cin >> a >> b;

	Out(max(a + b, max(a - b, a * b)));
	
	return 0;
}


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


long long permutationMethod(long long n,long long r){
    r = n - r;
    long long sum = 1;
    long long i;
    for (i=n;i>=r+1;i--)sum=(sum%1000000007*i)%(1000000007);
    return sum;
}

int main(int argc, char *argv[]){
  long long N,M;
  cin>>N>>M;
  long long sum=0;
  if(abs(N-M)>=2){
    cout<<0<<endl;
    return 0;
  }
  if(N==M){
  sum=((permutationMethod(N,N)*permutationMethod(M,M))*2)%1000000007;
  }
  else if(abs(N-M)==1){
    sum=((permutationMethod(N,N)*permutationMethod(M,M)))%1000000007;
  }
  cout<<sum<<endl;
}
  


Measured memory_bytes: 256
def main():
	x1, y1, x2, y2 = map(int, input().split())
	dx = x2 - x1
	dy = y2 - y1
	x3 = x2 - dy
	y3 = y2 + dx
	x4 = x3 - dx
	y4 = y3 - dy

	ans = str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4)
	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    var (mn, mx) = readLine()!!.split(" ").map { it.toInt() }
    for(i in 1 until y){
        var (tmpmn, tmpmx) = readLine()!!.split(" ").map { it.toInt() }
        mn = Math.max(mn, tmpmn)
        mx = Math.min(mx, tmpmx)
    }
    println(Math.max(mx - mn + 1, 0))
}

Measured memory_bytes: 55316
#include<stdio.h>
int main(){
    long long A,B,SUM;
    char op;
    scanf("%lld %c %lld",&A,&op,&B);
    if(op == '+'){
        SUM = A + B;
    }else if(op == '-'){
        SUM = A - B;
    }else if(op == '*'){
        SUM = A * B;
    }else if(op == '/'){
        if(B == 0){
            printf("B not is zero");
            return 0;
        }
        SUM = A / B;
    }
    printf("%lld",SUM);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int w,h,i,j;
int map[52][52];

void rec(int i,int j){
 
  if(map[i][j]==0)return;
  map[i][j]=0;
  rec(i+1,j);
  rec(i-1,j);
  rec(i,j-1);
  rec(i,j+1);
  rec(i-1,j-1);
  rec(i-1,j+1);
  rec(i+1,j-1);
  rec(i+1,j+1);
}
int main(){
  
  
  while(1){
    cin >> w >> h;
    if(w==0 && h==0)break;
    
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	cin >> map[i][j];
	
      }
    }
    int count=0;
    for(int k=1;k<=h;k++){
      for(int l=1;l<=w;l++){
	if(map[k][l]==1){
	  count++;
	  rec(k,l);
	}
      }
    }
    cout << count << endl;
  }
  
  return 0;
}

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

int main(void)
{
    int k; cin >> k;
    queue<long long> t;
    for (int i = 1; i < 10; i++) t.push(i);
    long long d, e;
    while (k > 0)
    {
        d = t.front(); k--; t.pop();
        for (int j = 0; j < 3; j++)
        {
            e = d % 10 + j - 1;
            if (e >= 0 && e < 10) t.push(d * 10 + e);
        }
    }
    cout << d << endl;
}

Measured memory_bytes: 5124
PROGRAM-ID.                      ABC_043_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N       PIC 9(3).
    01 tmp     PIC 9(4).
    01 ZS      PIC Z(5).
    01 ans     PIC X(18).
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT N.

    COMPUTE tmp = N * (N + 1) / 2.

    MOVE tmp TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


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

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  int t;
  if(P > Q)
    t = P;
  else
    t = Q;
  if(R > t)
    t = R;
  cout << P + Q + R - t << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int l = Integer.parseInt(sa[2]);
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i;
		}
		for (int i = 0; i < k; i++) {
			sa = br.readLine().split(" ");
			int p = Integer.parseInt(sa[0]) - 1;
			int q = Integer.parseInt(sa[1]) - 1;
			union(a, p, q);
		}

		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = i;
		}
		for (int i = 0; i < l; i++) {
			sa = br.readLine().split(" ");
			int r = Integer.parseInt(sa[0]) - 1;
			int s = Integer.parseInt(sa[1]) - 1;
			union(b, r, s);
		}
		br.close();

		long[] key = new long[n];
		Map<Long, Integer> map = new HashMap<Long, Integer>();
		for (int i = 0; i < n; i++) {
			key[i] = find(a, i) * 1000000L + find(b, i);
			if (map.containsKey(key[i])) {
				map.put(key[i], map.get(key[i]) + 1);
			} else {
				map.put(key[i], 1);
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(map.get(key[i])).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}

	static void union(int[] parent, int x, int y) {
		int px = find(parent, x);
		int py = find(parent, y);
		if (px != py) {
			parent[px] = py;
		}
	}

	static int find(int[] parent, int x) {
		if (parent[x] == x) {
			return x;
		}
		parent[x] = find(parent, parent[x]);
		return parent[x];
	}
}


Measured memory_bytes: 76536
N, M = (int(i) for i in input().split())
K = []
A = []
like_dict = {}
for i in range(N):
  KA = [int(j) for j in input().split()]
  K.append(KA[0])
  A.append(KA[1:])
for i in range(M):
  like_dict[i+1] = 0

for i in range(N):
  for j in range(K[i]):
    like_dict[A[i][j]] += 1

ans = 0

for i in range(1,M+1):
  if like_dict[i] == N:
    ans +=1

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int n,k,s=1,i;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        if(s*2>s+k)s+=k;
        else s*=2;
    }
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 128
s = input()
t = input()

ans = ''
# dp[i][j]:sをi文字目、tをj文字目まで見たときの最長部分列長
# dpに最長部分列そのものを持たせたら、TLEしてしまった。
dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j] + 1
    else:
      if dp[i+1][j] > dp[i][j+1]:
        dp[i+1][j+1] = dp[i+1][j]
      else:
        dp[i+1][j+1] = dp[i][j+1]
    #print(dp)
#print(dp)
#print(dp[len(s)][len(t)])

# dpを逆にたどって最長部分文字列を復元する
ans = ''
i = len(s)
j = len(t)
while(dp[i][j]>0):
  if dp[i][j] == dp[i-1][j]:
    i -= 1
  elif dp[i][j] == dp[i][j-1]:
    j -= 1
  else:
    ans += s[i-1]
    i -= 1
    j -= 1
print(''.join(reversed(list(ans))))


Measured memory_bytes: 119772
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
char ss[100004];
int len,numg,nump,ans;
int main()
{
	//freopen("AtCoDeer and Rock-Paper.in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",ss+1);
	len=strlen(ss+1);
	for(int i=1;i<=len;i++)
	{
		if(ss[i]=='g')
		{
			if(nump<numg) nump++, ans++; 
			else numg++;
		}
		else {
			if(nump<numg) nump++;
			else numg++, ans--;
		}
	}
	printf("%d\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<numeric>
#include<map>
#include<math.h>

using namespace::std;

int main(void)
{
  int n;
  vector<int> s;

  while(cin >> n && n != 0)
    {
      int tempS;
      s.clear();

      for(int i = 0; i < n; i++)
	{
	  cin >> tempS;
	  s.push_back(tempS);
	}

      sort( s.begin() , s.end() );
      int ans=0;
      for(int i = 1; i < n-1; i++)
	{
	  ans+=s[i]; 
	}
      cout << ans/( n - 2 ) << endl;
    }

  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n, x, a[100], sum = 0;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(int), cmpint);
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (sum > x) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf("%d\n", sum == x ? n : n - 1);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def print_ans(N, S, T):
    """Test Case
    >>> print_ans(2, "ip", "cc")
    icpc
    >>> print_ans(8, "hmhmnknk", "uuuuuuuu")
    humuhumunukunuku
    >>> print_ans(5, "aaaaa", "aaaaa")
    aaaaaaaaaa
    """
    ans = []
    for i in range(N):
        ans.append(S[i])
        ans.append(T[i])
    print(''.join(ans))

if __name__ == '__main__':
    N = int(input().rstrip())
    S, T = input().rstrip().split()
    print_ans(N, S, T)




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

int main() {
	int n,k;
	cin>>n>>k;
	double N = static_cast<double>(n);
	double K = static_cast<double>(k);
	double ans = 0;
	for(int i = 1; i <= n; i++){
		double v = static_cast<double>(i);
		int j = 0;
		double p = 1/N;
		while(j<log2(K/v)){
			p *= 0.5;
			j++;
		}
		// cout << p << endl;
		ans += p;
	}
	cout << setprecision(11) << ans << endl;
}


Measured memory_bytes: 256
def gcd(a, b):
    bigger = max(a, b)
    smaller = min(a, b)
    while smaller != 0:
        bigger, smaller = smaller, bigger % smaller
    return bigger


N = int(input())
A = list(map(int, input().split()))
gcd_l = [A[0]] + [0] * (N - 1)
for i in range(1, N):
    gcd_l[i] = gcd(gcd_l[i - 1], A[i])
del gcd_l[-1]

gcd_r = [0] * (N - 1) + [A[-1]]
for i in range(N - 1, 0, -1):
    gcd_r[i - 1] = gcd(gcd_r[i], A[i - 1])
del gcd_r[0]

gcds = [gcd_l.pop(), gcd_r.pop(0)]
for l, r in zip(gcd_l, gcd_r):
    gcds.append(gcd(l, r))
print(max(gcds))


Measured memory_bytes: 14428
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    VI a;
    queue<int> q;
    for(int i = 1; i < 10; ++i){
        q.push(i);
    }
    while(!q.empty()){
        int num = q.front();
        q.pop();
        a.push_back(num);
        if (num * 10 < 3234566667){
            int d = num % 10;
            if (d != 0){
                q.push(num * 10 + d - 1);
            }
            q.push(num * 10 + d);
            if (d != 9){
                q.push(num * 10 + d + 1);
            }
        }
    }
    sort(ALL(a));
    make(int, k);
    cout << a[k - 1];

    return 0;
}

Measured memory_bytes: 1912
s = input()
# print(s)
n: int = 0
odds = ""


for i in s:
    if n % 2 == 0:
        odd = s[n]
        odds += odd
    elif n == 0:
        odd = s[n]
        odds += odd
    else:
        pass
    n += 1
    # nを奇数にする
print(odds)

Measured memory_bytes: 9188