akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int h, w; cin >> w >> h; std::vector<std::pair<long, int>> vec;
	for(int i = 0; i < h + w; i++){
		int a; cin >> a;
		
		vec.push_back({a, i < w});
	}
	sort(begin(vec), end(vec));
	
	long A = h + 1, B = w + 1, ans = 0;
	for(int i = 0; i < h + w; i++){
		if(vec[i].second){
			if(!B) continue;
			ans += A * vec[i].first;
			B--;
		}else{
			if(!A) continue;
			ans += B * vec[i].first;
			A--;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6512
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray().toList()
    
    // 1枚目を0にしたときと1にしたときで小さい方を出力
    
    val start0 = s.filterIndexed { index, c -> if (index % 2 == 0) c != '0' else c != '1' }
    val start1 = s.filterIndexed { index, c -> if (index % 2 == 0) c != '1' else c != '0' }
    
    if (start0.size < start1.size) {
        println(start0.size)
    } else {
        println(start1.size)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

int main()
{
  vector< int > a(3), b(3);
  cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];
  if(a > b) swap(a, b);
  int add = 0;
  if(a[1] < b[1]) ++add;
  else if(a[1] == b[1] && a[2] < b[2]) ++add;
  cout << b[0] - a[0] + add << endl;
}

Measured memory_bytes: 3092
N, K = map(int, input().split())
D = list(map(int, input().split()))
usenum = set()
for i in range(10):
    if not i in D:
        usenum.add(str(i))

for i in range(N, N*10+1):
    t = set(str(i))
    if t.issubset(usenum):
        print(i)
        break


Measured memory_bytes: 40300
#include <bits/stdc++.h>
using namespace std;
int n,m,d;
int main(){
	scanf("%d%d%d",&n,&m,&d);
	double ans=1.0*(m-1)*(1.0*(2*n-2*d)/n/n);
	if (d==0)
		ans/=2;
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 256
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int64_t N,M,C;
  cin >> N >>M>>C;
  vector<int>B(M);
  int count=0;
  rep(i,M)cin >> B.at(i);
  vector<vector<int>> A(N, vector<int>(M));//int型の2次元配列(3×4要素の)の宣言  
  rep(i,N){
    rep(j,M){
      cin >> A.at(i).at(j);
    }
  }
/*
  rep(i,M){
    cout<<	B.at(i);
  }
    cout<<endl;
  rep(i,N){
    rep(j,M){
	cout<<	A.at(i).at(j);
    }
    cout<<endl;
  }
*/  
  
  
  rep(i,N){ 
      int sum=0;
    rep(j,M){
      sum+= B.at(j)*A.at(i).at(j);
    }
    if(sum+C > 0)count++;
  }
  cout << count<< endl;
}


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

int s[200005];
int cnt[200005];

int fa(int x){
    return s[x]==x ? x : (s[x] = fa(s[x]));
}

void merge(int a,int b){
    int t1 = fa(a);
    int t2 = fa(b);
    if(t1 != t2)
       s[t1] = t2;
}


int main()
{
    int n,m;
    cin >> n >> m;
    for (int i = 1; i <= n;i++)
        s[i] = i;
    for (int i = 0; i < m;i++){
        int a, b;
        cin >> a >> b;
        merge(a, b);
    }

    int ans = 0;

    for (int i = 1; i <= n;i++)
        ans = max(ans, ++cnt[fa(i)]);

    cout << ans;
    return 0;
}


Measured memory_bytes: 10524
/* #region template */
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn collect<'b, T: FromStr>(&'b mut self, n: usize) -> Vec<T>
    where
        'a: 'b,
    {
        self.iter().take(n).collect()
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    solve(&mut io);
}
/* #endregion */

const BUF_SIZE: usize = 1024;
fn solve(io: &mut Io) {
    let n = io.ru();
    let k = io.ru();
    let w = io.collect::<usize>(n);

    let r = binary_search(*w.iter().max().unwrap(), 1000000000, |m| {
        let mut t = 0;
        let mut sum = 0;
        for wi in &w {
            sum += *wi;
            if sum > m {
                t += 1;
                if t == k {
                    return Less;
                }
                sum = *wi;
            }
        }

        Greater
    });

    io.w(r.0 + r.1);
}

use std::cmp::Ordering::*;
fn binary_search<F>(min: usize, max: usize, mut f: F) -> (usize, usize)
where
    F: FnMut(usize) -> std::cmp::Ordering,
{
    let mut left = min;
    let mut right = max;

    while right - left > 1 {
        let center = (left + right) / 2;
        match f(center) {
            Less => left = center + 1,
            Equal => return (center, 0),
            Greater => right = center,
        }
    }

    match f(left) {
        Less => (left, 1),
        Equal => (left, 0),
        Greater => (left - 1, 1),
    }
}



Measured memory_bytes: 5036
def main():
    N = int(input())
    S = list(input())

    CW = [0 for i in range(N + 1)]
    CE = [0 for i in range(N + 1)]

    count_w = count_e = 0

    for i in range(N):
        if S[i] == "W":
            count_w += 1
        CW[i + 1] = count_w

    S.reverse()
    
    for i in range(N):
        if S[i] == "E":
            count_e += 1
        CE[i + 1] = count_e

    S.reverse()

    ans = 10**6
    for i in range(N):
        w = CW[i] - CW[0]
        e = CE[N - (i + 1)] - CE[0]
        change = w + e

        if ans > change:
            ans = change

    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((c + b - 1) / b <= (a + d - 1) / d)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const ll INF = 1e16;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


struct Event{
    ll l,r,cost;
    bool operator>(const Event &right)const{
        return l > right.l;
    }
};
using P = pair<ll,ll>;

int main(void){
    ll n,m;
    cin >> n >> m;
    priority_queue<Event,vector<Event>,greater<Event>> eventQ;
    priority_queue<P,vector<P>,greater<P>> paths;
    rep(i,m){
        ll l,r,c;
        cin >> l >> r >> c;
        eventQ.push({l,r,c});
    }

    paths.push({0,1});
    paths.push({INF,n+1});
    while(eventQ.size()){
        Event e = eventQ.top(); eventQ.pop();
        while(paths.top().second < e.l) paths.pop();
        paths.push({paths.top().first + e.cost, e.r});
    }
    while(paths.top().second < n) paths.pop();
    cout << ((paths.top().first < INF) ? paths.top().first : (ll)-1) << endl;

    return 0;
}


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

using namespace std;

string s;

int b1,b2, ans;
int main()
{
    cin>>s;
    int lung = s.size();
    int bit = 0;
    for (int i=0; i<lung; i++)
    {
        if ((s[i]-'0')!=bit)
            b1++;
        bit = 1-bit;
    }

    bit = 1;
    for (int i=0; i<lung; i++)
    {
        if ((s[i]-'0')!=bit)
            b2++;
        bit = 1-bit;
    }

    ans = min(b1, b2);
    cout<<ans;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000000
#define MOD 1000000007 
#define N 360005
#define M 1000000
#define LOG 20
#define KOK 300
#define EPS 0.0000001
using namespace std;

int ok[N],vis[N];
int n,d[2];
vector<int> v[2][N];
vector<int> has[2];

int gnode(int a,int b) {

	return (a-1)*2*n+b;

}

void dfs(int node,int gr,int t) {

	if(vis[node] || !ok[node]) return ;

	vis[node]=1;

	has[gr].pb(node);

	for(auto x:v[t][node]) {

		dfs(x,!gr,t);

	}

}

void add_edge(int a,int b,int c,int d,int t) {

	if(c>2*n || c<1 || d>2*n || d<1) return ;

	int n1=gnode(a,b);
	int n2=gnode(c,d);

	v[t][n1].pb(n2);
	v[t][n2].pb(n1);

}

int w[4][2]={1,1,-1,1,1,-1,-1,-1};

int main() {

	scanf("%d %d %d",&n,&d[0],&d[1]);

	vector<ii> go[2];

	for(int t=0;t<2;t++) {

		for(int i=0;i*i<=d[t];i++) {

			int r=d[t]-i*i;
			int sq=sqrt(r);

			if(sq*sq==r) {

				for(int j=0;j<4;j++) {

					go[t].pb({w[j][0]*i,w[j][1]*sq});
					go[t].pb({w[j][0]*sq,w[j][1]*i});

				}

			}

		}

	}

	for(int i=1;i<=2*n;i++) {

		for(int j=1;j<=2*n;j++) {

			ok[gnode(i,j)]=1;

			for(int t=0;t<2;t++) {

				for(auto sp:go[t]) {

					add_edge(i,j,i+sp.st,j+sp.nd,t);

				}

			}

		}

	}

	for(int t=0;t<2;t++) {

		for(int i=1;i<=4*n*n;i++) {

			if(ok[i] && !vis[i]) {

				dfs(i,0,t);

				if(sz(has[1])>sz(has[0])) swap(has[0],has[1]);

				for(auto x:has[1]) ok[x]=0;

				has[0].clear();
				has[1].clear();

			} 

		}

		memset(vis,0,sizeof(vis));
	
	}

	int cnt=0;

	for(int i=1;i<=2*n;i++) {

		for(int j=1;cnt<n*n && j<=2*n;j++) {

			if(ok[gnode(i,j)]) {

				cnt++;

				printf("%d %d\n",i-1,j-1);

			}

		}

	}

}	

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

int main() {
    int n;
    cin >> n;
    if (n < 1200) {
        cout << "ABC" << endl;
    }
    else if (n < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int h, w;
  int ci = 0, cj = 0;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> a.at(i).at(j);
    }
  }

  //行ごとに
  for (int i = 0; i < h; i++)
  {
    bool b = true;
    for (int j = 0; j < w; j++)
    {
      if (a.at(i).at(j) == '#')
      {
        b = false;
        break;
      }
    }
    if (b)
    {
      for (int di = i; di < h; di++)
      {
        for (int j = 0; j < w; j++)
        {
          if (di != h - 1)
          {
            a.at(di).at(j) = a.at(di + 1).at(j);
          }
          else
          {
            a.at(di).at(j) = 'f';
          }
        }
      }
      ci++;
      i--;
    }
    if (ci == h - 1)
    {
      break;
    }
  }
  //列ごとに
  for (int j = 0; j < w; j++)
  {
    bool b = true;
    for (int i = 0; i < h; i++)
    {
      if (a.at(i).at(j) == '#')
      {
        b = false;
        break;
      }
    }
    if (b)
    {
      for (int dj = j; dj < w; dj++)
      {
        for (int i = 0; i < h; i++)
        {
          if (dj != w - 1)
          {
            a.at(i).at(dj) = a.at(i).at(dj + 1);
          }
          else
          {
            a.at(i).at(dj) = 'f';
          }
        }
      }
      cj++;
      j--;
    }
    if (cj == w - 1)
    {
      break;
    }
  }
  //output
  bool f = true;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if(a.at(i).at(j)=='f'){
        if(j==0){
          f = false;
          break;
        }else{
          break;
        }
      }else{
        cout << a.at(i).at(j);
      }
    }
    if (!f)
      break;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val s = readLine()!!
    val sList = s.groupBy { it }

    var minCnt = Int.MAX_VALUE

    sList.forEach {
        val target = it.key
        val ts = target.toString().repeat(s.length)
        var ss = s
        var cnt = 0

        while (ss != ts.drop(cnt)) {
            var tmp = ""
            for (i in 0 until ss.length-1) {
                if (ss[i+1] == target) {
                    tmp += ss[i+1]
                } else {
                    tmp += ss[i]
                }
            }
            ss = tmp
            cnt++
        }

        minCnt = Math.min(minCnt, cnt)
    }

    println(minCnt)
}



Measured memory_bytes: 45920
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	dup := "Good"
	chars := strings.Split(s, "")
	for i := 1; i < len(chars); i++ {
		if chars[i] == chars[i-1] {
			dup = "Bad"
			break
		}
	}
	fmt.Println(dup)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1e9+7;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vl x(n);
	vl y(m);
	rep(i,0,n) {
		cin >> x[i];
	}
	rep(i,0,m) {
		cin >> y[i];
	}
	sort(all(x));
	sort(all(y));
	ll totalX = 0;
	ll totalY = 0;
	rep(i,1,n) {
		ll dx = x[i] - x[i-1];
		ll cnt = (ll)i * (n-i);
		totalX += dx*cnt;
		totalX %= MOD;
	}
	rep(i,1,m) {
		ll dy = y[i] - y[i-1];
		ll cnt = (ll)i * (m-i);
		totalY += dy*cnt;
		totalY %= MOD;
	}
	cout << (totalX * totalY) % MOD << '\n';
	return 0;
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	ll N, K;
	cin >> N >> K;
	vector <int> input( N );
	vector <int> visited( N, 0 );
	rep( i, 0, N ){
		int in; cin >> in;
		input[ i ] = in - 1;
	}
	int cnt = 0, pos = 0;
	while(visited[ pos ] == 0){
		cnt++;
		visited[ pos ] = cnt;
		pos = input[ pos ];
	}
	if (K > visited[ pos ] - 1){
		K -= visited[ pos ] - 1;
		K %= cnt - visited[ pos ] + 1;
		K += visited[ pos ] - 1;
	}
	pos = 0;
	rep( i, 0, K ){
		pos = input[ pos ];
	}
	cout << pos + 1 << endl;

}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

int main()
{
    int A,B,C,K;
    cin>>A>>B>>C>>K;

    int dp[3];
    dp[0] = A;
    dp[1] = A + B;
    dp[2] = dp[1] + C;

    if(dp[0]>K)
    {
        cout<<K<<endl;
        return 0;
    }
    if(dp[0]==K)
    {
        cout<<A;
        return 0;
    }
    if(dp[1]>=K)
    {
        cout<<A;
        return 0;
    }
    if(dp[2]>=K)
    {
        cout<<A - (K - dp[1])<<endl;
    }

    
    return 0;
    
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main()
{
    ll n, ans = 0,ans2=0;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));

    ans += v[n - 1] - v[0];
    ans += v[n - 2] - v[0];
    ans2=ans;
    for (int i = 1; i <= n - (n + 1) / 2; i++)
    {
        ans += v[n - i] - v[i];
        if(n-2-i>=(n+1)/2)ans += v[n - 2 - i] - v[i];
    }


    for (int i = 1; i <= n-n/2; i++)
    {
        ans2 += v[n - i] - v[i];
        if(n-2-i >= n/2)ans2 += v[n - 2 - i] - v[i];
    }

    cout<<max(ans,ans2)<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e14;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int odd = 0;
  REP(i, n) if ((i+1)%2) odd++;
  cout << setpre(10) << (double)odd/(double)n << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    for(int i=0;i<(1<<n);i++){
        cout<<i<<':';
        for(int j=0;j<n;j++){
            if(i>>j&1) cout<<' '<<j;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3104
#include <stdio.h>

  int main(void){

    int a,b,c;
    scanf("%d",&a);

    if(a == 1){
      printf("Hello World\n");
    } else if(a == 2){
      scanf("%d",&b);
      scanf("%d",&c);
      printf("%d\n",b+c);
    }

    return 0;

  }


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
   char s[4];

   scanf("%c%c%c%c", &s[0], &s[1], &s[2], &s[3]);

   if (s[0] == s[1])
      printf("Bad\n");
   else if (s[1] == s[2])
      printf("Bad\n");
   else if (s[2] == s[3])
      printf("Bad\n");
   else 
      printf("Good\n");

   return 0;
}


Measured memory_bytes: 128
let input = require('fs').readFileSync( '/dev/stdin', 'utf8' );
let arr = input.split("\n");
for (let i = 0; i < arr.length; i ++) {
    let ab = arr[i].split(" ").map(Number);
    if (ab[0] === 0 && ab[1] === 0) break;
    console.log("%d %d",  Math.min(ab[0], ab[1]), Math.max(ab[0], ab[1]));
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[3][3];
  rep(i,3)rep(j,3)cin>>a[i][j];
  int n;cin>>n;
  rep(i,n){
    int tmp;
    cin>>tmp;
    rep(k,3)rep(j,3)if(a[k][j]==tmp)a[k][j]=-1;
  }
  bool s=0;
  rep(i,3)if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1)s=1;
  rep(i,3)if(a[0][i]==-1&&a[1][i]==-1&&a[2][i]==-1)s=1;
  if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)s=1;
  if(a[2][0]==-1&&a[1][1]==-1&&a[0][2]==-1)s=1;
  if(s==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int n, number;
    int count = 0;
    vector <int> numbers;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> number;
        if(number % 2 == 0)
            numbers.push_back(number);
    }

    for(int j = 0; j < numbers.size(); j++) {
        while(numbers[j] % 2 == 0){
            numbers[j] /= 2;
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, a, b; cin >> n >> a >> b;
  vector<ll> v(n);
  ll res = 0;
  ll p; cin >> p;
  for (int i = 0; i < n-1; i++) {
    ll x; cin >> x;
    res += min((x - p) * a, b);
    p = x;
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    string str;
    cin >> str;
    int ans = 0;
    FOR(i,str.length()){
        if(str[i]=='+')
            ans++;
        else
            ans--;
    }
    cout << ans fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
long long sum = 0;
int a[10005];
int b[10005];

int main(){

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

    for(int i = 1;i <= n;i++){
        cin >> b[i];
    }

    long long sum_b = 0;
    long long sum_s = 0;

    for(int i = 1;i <= n;i++){
        if(a[i] >= b[i]){
            sum_b += a[i] - b[i];
        }
        else{
            sum_s += (b[i] - a[i]) / 2;
        }
    }

    cout << (sum_b <= sum_s ? "Yes":"No");

    return 0;
}


Measured memory_bytes: 384
n = int(input())
dp = [0] * 11000
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            x = i**2+j**2+k**2+i*j+j*k+k*i
            if x <= 10**4:
                dp[x] += 1
for i in range(1,n+1):
    print(dp[i])

Measured memory_bytes: 69192
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

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

    map<char, int> MS, MT;
    for (char c : S) {
        MS[c]++;
    }
    for (char c : T) {
        MT[c]++;
    }
    vector<int> VS, VT;
    for (auto i : MS) {
        VS.push_back(i.second);
    }
    for (auto i : MT) {
        VT.push_back(i.second);
    }
    sort(VS.begin(), VS.end());
    sort(VT.begin(), VT.end());
    if (VS == VT) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
int main()
{
    ARB
    int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    k--;
    cout<<arr[k];
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, 0, 3) {
        if(S[i] == T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;


int main(){
    int n;
    cin >> n;
    long sum=1;


    for(int i=1;i<=n;i++){
        sum *= i;
        sum %= MOD;
    }

    

    cout << sum << endl;

}

Measured memory_bytes: 256
#include<iostream>

int S[10001], T[501];

int main(){
	int n, m;
	std::cin >> n;
	for(int i = 0; i < n; ++i){
		std::cin >> S[i];
	}
	std::cin >> m;
	for(int i = 0; i < m; ++i){
		std::cin >> T[i];
	}
	int ans = 0;
	for(int i = 0; i < m; ++i){
		for(int j = 0; j < n; ++j){
			if(T[i] == S[j]){
				ans++;
				break;
			}
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

int dfs(int v, vector<vector<int>>& to, vector<int>& dist) {
    if (dist[v] >= 0) return dist[v];

    int res = 0;
    for (auto e : to[v]) res = max(res, dfs(e, to, dist) + 1);
    dist[v] = res;
    return res;
}

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

    int n, m;
    cin>>n>>m;
    vector<vector<int>> to(n);
    rep(i, m) {
        int x, y;
        cin>>x>>y; x--; y--;
        to[x].push_back(y);
    }

    vector<int> dist(n, -1);
    int ans = 0;
    rep(i, n) {
        ans = max(ans, dfs(i, to, dist));
    }
    cout<<ans<<endl;
}

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

int main(){
  int D, S, T;
  cin >> D >> T >> S;
  
  string ans;
  if (D <= T * S){
    ans ="Yes";
  }
  else{
    ans = "No";
  }
  
  cout << ans << endl;
}

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

int main(){
    
    ll a, b, r, x, tmp;
 
    cin >> a >> b;
    
    x = a * b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    
    ll answer = x/b;
    cout << answer << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int sum=0;
	if(a==b)sum++;
	if(a==c)sum++;
	if(b==c)sum++;
	if(sum==1)
		cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



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

int main(void){
    int N;
    int64_t r[100];
    cin >> N;
    for (int i = 0; i <= N; i++){
        r[i] = 0;
        r[0] = 2;
        r[1] = 1;
    }
    for (int i = 2; i <= N; i++){
        r[i] = r[i - 1] + r[i - 2];
    }
    cout << r[N] << endl; 
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX

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

    ll n, p;
    cin >> n >> p;
    map <ll, ll> mp;
    for (ll i = 2; i * i <= p; i++) {
        ll c = 0;
        if (p % i == 0) {
            while (p % i == 0) {
                p /= i;
                c++;
            }
            mp[i] += c;
        }
    }
    if (p) {
        mp[p] = 1;
    }
    ll ans = 1;
    for (auto it : mp) {
        ll a = it.first;
        ll b = it.second;
        ll d = b / n;
        ans *= pow(a, d);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int a; char b; string c;
  int cnt[4] = {0};
  map<string,int> m;
  m["A"]  = 0;
  m["B"]  = 1;
  m["AB"] = 2;
  m["O"]  = 3;
  while(cin>>a>>b>>c){
    cnt[m[c]]++;
  }
  REP(i,4) cout<<cnt[i]<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
int32_t main(){ fast;
	ll a, b; cin>>a>>b;
	ll ans = 1;
	while(true){
		a *= 2;
		if(a > b) break;
		ans++;
	}
	cout<<ans<<endl;
}


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

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

	int d;
	cin >> d;

	if (d == 22) cout << "Christmas Eve Eve Eve\n";
	else if (d == 23) cout << "Christmas Eve Eve\n";
	else if (d == 24) cout << "Christmas Eve\n";
	else if (d == 25) cout << "Christmas\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = 0;
    int start = min(a, b);
    int fin = max(c, d);
    repd(i, start, fin) {
        if (a <= i && i < b && c <= i && i < d) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    # 終点はルート切り捨て+1
    for i in range(2, int(sqrt(num))+1):
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

class FactInvMOD:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def nPr(self, n, r):
        """ 順列 """

        if n < r: return 0
        return self.fact[n] * self.inv[n-r] % self.MOD

    def nHr(self, n, r):
        """ 重複組み合わせ """

        # r個選ぶところにN-1個の仕切りを入れる
        return self.nCr(r+n-1, r)

N, M = MAP()

d = factorize(M)

# 例外処理
if not d:
    print(1)
    exit()

MAX = N + max(d.values())
fim = FactInvMOD(MAX, MOD)
ans = 1
for k, v in d.items():
    ans *= fim.nHr(N, v)
    ans %= MOD
print(ans)


Measured memory_bytes: 11240
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

//Union-Find木
struct UnionFind{
private:
    vector<int> parent;
public:
    UnionFind(int N) : parent(N){ //初期化する O(N)
        for(int i=0; i<N; i++) parent[i] = i;
    }
    int root(int a){ //親を返す O(log N)
        if(parent[a] == a) return a;
        return parent[a] = root(parent[a]);
    }
    void unite(int a, int b){ //木を併合する O(log N)
        int rootA = root(a);
        int rootB = root(b);
        if(rootA != rootB) parent[rootA] = rootB;
    }
    bool same(int a, int b){ //属する木が同じかを返す O(log N)
        return root(a) == root(b);
    }
};

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int a[100000],b[100000];
    vector<pair<int,int> > c;
    for(int i=0; i<N; i++){
        cin >> a[i];
        b[i] = a[i];
        c.push_back(MP(a[i], i));
    }

    UnionFind uf(N);

    //素因数分解
    map<int,int> so;
    for(int i=0; i<N; i++){
        for(int j=2; j<=sqrt(a[i])+1; j++){
            if(a[i] % j == 0){
                a[i] /= j;
                auto itr = so.find(j);
                if(itr == so.end()) so[j] = i;
                else uf.unite(i,itr->second);
                j--;
            }
        }
        if(a[i] != 1){
            auto itr = so.find(a[i]);
            if(itr == so.end()) so[a[i]] = i;
            else uf.unite(i,itr->second);
        }
    }

    //判定
    sort(c.begin(), c.end());
    for(int i=0; i<N; i++){
        if(!uf.same(i, c[i].second)){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int ans=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    ans+=a[i]-1;
  }
  cout << ans <<endl;
}

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

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

print(ans)

Measured memory_bytes: 21784
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    int x = min(a, k);
    a -= x; k -= x;
    if(k) {
        int y = min(b, k);
        b -= y; k -= y;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, 0)
min_diff = float('inf')
for i in range(1, n + 1):
    temp = t - h[i] * 0.006
    if abs(a - temp) < min_diff:
        min_diff = abs(a - temp)
        ans = i
print(ans)

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  ll a,b,res = 1;
  bool flag = true;
  cin >> a >> b;
  ll gcd = __gcd(a,b);
  for(ll i = 2;i*i <= gcd;i++)if(!(gcd%i))flag = false;
  if(flag){
    if(gcd == 1){
      cout << 1;
      return 0;
    }
    cout << 2;
    return 0;
  }
  for(ll i = 2;i <= gcd;i++){
    if(flag){
      res++;
      break;
    }
    if(gcd%i)continue;
    flag = true;
    while(!(gcd%i)){
      gcd /= i;
    }
    res++;
    for(ll j = 2;j*j <= gcd;j++)if(!(gcd%j))flag = false;
  }
  cout << res;

  return 0;
}

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

int A, B, C, D, E, F;

int main() {
   cin >> A >> B >> C >> D >> E >> F;

   // 砂糖、水をそれぞれ独立して作る
   set<int> waterSet, sugarSet;

   // 水
   for (int i = 0; i <= 33; i++) {
      for (int j = 0; j <= 33; j++) {
         int w = 100*A*i + 100*B*j;
         if (w <= F) waterSet.insert(w);
      }
   }

   // 砂糖
   for (int i = 0; i < 3010; i++) {
      for (int j = 0; j < 3010; j++) {
         int s = C*i + D*j;
         if (s <= F) sugarSet.insert(s);
      }
   }
  
   const double nLim = (double)E/(100+E); // 濃度の限界値
   double noudo = -1; // 初期値を-1にしないと一度も更新されなくなってしまう
   int ans1 = 0, ans2 = 0;
   for (int s : sugarSet) {
      for (int w : waterSet) {
         int sum = s + w; // 砂糖水
         double x = (double)s/sum; // 作った砂糖水の濃度
         if (sum <= F && x <= nLim && x > noudo) { // 条件を満たす && 濃度が最大値
            noudo = x;
            ans1 = sum, ans2 = s;
         }
      }
   }
   printf("%d %d\n", ans1, ans2);

   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
//解説AC
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  map<int,int>mph,mpw;
  set<pair<int,int>>zahyou;
  rep(i,n){
    int r,c;
    cin>>r>>c;
    zahyou.insert({r,c});
    mph[r]++;
    mpw[c]++;
  }
  int maxh=0;
  for(auto p:mph)chmax(maxh,p.second);
  int maxw=0;
  for(auto p:mpw)chmax(maxw,p.second);
  vector<int>numh,numw;
  for(auto p:mph)if(p.second==maxh)numh.push_back(p.first);
  for(auto p:mpw)if(p.second==maxw)numw.push_back(p.first);
  rep(i,numh.size())rep(j,numw.size()){
    if(!zahyou.count({numh[i],numw[j]})){
      cout<<maxh+maxw<<endl;
      return 0;
    }
  }
  cout<<maxh+maxw-1<<endl;
  return 0;
}

Measured memory_bytes: 49652
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;
template<typename A, typename B>inline void chmin(A &a, B b) { if (a > b)a = b; }
template<typename A, typename B>inline void chmax(A &a, B b) { if (a < b)a = b; }

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if (H%h == 0 && W%w == 0 ) {
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	int num = 999;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (i%h == 0 && j%w == 0) {
				cout <<-num* (h*w-1)-1;
			}
			else {
				cout << num;
			}
			if (j != W)cout << " ";
			else cout << endl;
		}
	}
	//system("pause");
}

Measured memory_bytes: 1408
S=list(input())
N=int(input())

i=0
while i<len(S)-1:
    if S[i]!='a' and 123-ord(S[i])<=N:
        N-=123-ord(S[i])
        S[i]='a'
    i+=1

N=N%26
while N:
    if S[-1]=='z':
        S[-1]='a'
    else:
        S[-1]=chr(ord(S[-1])+1)
    N-=1

print(''.join(S))


Measured memory_bytes: 49520
#include<bits/stdc++.h>
using namespace std;
main(){
  vector<vector<int>> c(3,vector<int>(3));
  for(auto& ci:c)for(auto& cij:ci)cin>>cij;
  
  for(int i=0;i<=100;++i){
    for(int j=0;j<=100;++j){
      for(int k=0;k<=100;++k){
        vector<int> a={i,j,k};
        // c[i][j] = a[i]+b[j];
        // b[j] = c[i][j]-a[i];
        vector<vector<int>> b(3,vector<int>(3));
        bool brk=false;
        for(int l=0;l<3;++l){
          for(int m=0;m<3;++m){
            b[l][m]=c[l][m]-a[l];
            if(b[l][m]<0)brk=true;
            if(brk)break;
          }
          if(brk)break;
        }
        if(brk)continue;
        if(b[0]==b[1]&&b[1]==b[2]){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
}

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

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

int main()
{
    string S;
    map<string, string> m;
    cin >> S;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";
    cout << m[S] << endl;
}

Measured memory_bytes: 256