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

int main() {
  string s, t; cin >> s >> t;
  bool answer = true;
  
  vector<char> sv(s.size());
  vector<char> tv(t.size());
  
  for (int i = 0; i < s.size(); i++) sv.at(i) = s.at(i);
  for (int i = 0; i < t.size(); i++) tv.at(i) = t.at(i);
  
  sort(sv.begin(), sv.end());
  sort(tv.rbegin(), tv.rend());
  
  for (int i = 0; i < min(s.size(), t.size()); i++) {
    if (sv.at(i) < tv.at(i)) {
      break;
    } else if (sv.at(i) > tv.at(i)) {
      answer = false;
      break;
    }
    if (i == min(s.size(), t.size()) - 1) {
      if (s.size() >= t.size()) answer = false;
    }
  }
  
  if (answer) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int n,m,q;
	cin >> n>>m>>q;

	vector<vector<int>> input(q,vector<int>(4));
	rep(i,q){
		rep(j,4){
			cin >> input[i][j];
		}
	}

	vector<int> a;
	int score = 0;

	vector<int> dfs;

	for(int i = m; i>= 1; i--){
		dfs.push_back(i);
	}

	while(!dfs.empty()){
		// cout << "dfs:";
		// rep(i,dfs.size()) cout << dfs[i] << ",";
		// cout << endl;

		//cout << "dfs[-1]:" << dfs.back() <<endl;

		a.push_back(dfs.back());
		//cout << "a_push\n";

		// cout << "a:";
		// rep(i,a.size())cout << a[i] << ",";
		// cout << endl;

		if(a.size() == n){
			//cout << "asize = " << n << endl;
			int subscore = 0;
			rep(i,q){
				if(a[input[i][1]-1]-a[input[i][0]-1] == input[i][2]){
					subscore += input[i][3];	
				}
			}
			score = max(score,subscore);
			//cout << "score:" << score << ", subscore:" << subscore << endl;

			while( a.size() >0 && dfs.back() == a.back() ){
				dfs.pop_back();
				a.pop_back();
			}
		}

		else{
			//cout << "dfs_push\n";
			for(int i = m; i>= a.back();i--){
				dfs.push_back(i);

				// cout << "dfs:";
				// rep(i,dfs.size()) cout << dfs[i] << ",";
				// cout << endl;
			}
		}
		//sleep(1);
	}

	cout << score << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int a,b,i;
  int result,vala,valb;
  scanf("%d %d",&a,&b);
  for(i=10;i<=1250;i++){
  vala=(int)i*0.08;
  valb=(int)i*0.1;
  if(vala==a && valb==b){
   printf("%d",i);
    return 0;
  }
  }
  printf("-1");
    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for(i=0; i<N; i++){
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }

  printf("\n");
}

void insertionSort(int A[], int N){
  int i, j, v;
  for(i=1; i<N; i++){
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

int main(){
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for(i=0; i<N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}

     



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

int main(){
    /*
    int N, K;
    cin >> N >> K;
    */
    string st;
    cin >> st;
    int f = 0;
    if(st.at(2) != st.at(3)) f = 1;
    if(st.at(4) != st.at(5)) f = 1;
    if(f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let k: usize = read();
    let mut s: Vec<usize> = vec![];
    for i in 1..10 {
        s.push(i)
    }
    for _ in 0..9 {
        let mut nexts = vec![];
        for e in &s {
            let n = e % 10;
            match e.checked_mul(10usize) {
                Some(v) => {
                    if n == 0 {
                        nexts.push(v + 1);
                        nexts.push(v);
                    } else if n == 9 {
                        nexts.push(v + 8);
                        nexts.push(v + 9);
                    } else {
                        nexts.push(v + n);
                        nexts.push(v + n + 1);
                        nexts.push(v + n - 1);
                    }
                }
                None => {
                    break;
                }
            }
        }
        s.extend(nexts.iter());
        s.sort();
        s.dedup();
    }
    // println!("{:?}", s.len());
    println!("{}", s[k - 1]);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main()
{
    int n, m;
    cin >> n >> m;
    int* a = new int[n];
    int count = 0;
    for(int i = 0; i < m; i++)
    {
        int homework = 0;
        cin >> homework;
        count += homework;
    }

    int free = n - count;
    if(free < 0)
    {
        cout << -1;
    }
    else
    {
        cout << free;
    }  



    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string atcoder,s,contest;
    cin >> atcoder >> s >> contest;
    cout << atcoder[0] << s[0] << contest[0] << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine() ?: return
    val builder = StringBuilder()
    input.forEach {
        val newC = when {
            it.isLowerCase() -> it.toUpperCase()
            it.isUpperCase() -> it.toLowerCase()
            else -> it
        }
        builder.append(newC)
    }
    println(builder.toString())
}


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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for(int i = 0; i < 3; i++){
  for(int j = 0; j < 3; j++){
	cin >> a[i][j];
  }
  }
  bool ans = false;
  int n; cin >> n;
  vector<int> b(n);
  for(int k = 0; k < n; k++){
  	cin >> b[k];
  
  	for(int i = 0; i < 3; i++){
  	for(int j = 0; j < 3; j++){
  		if(b[k] == a[i][j]) a[i][j] = 0;
    }
    }
  }
  
  for(int i = 0; i < 3; i++){
  	if(a[i][1]+a[i][0]+a[i][2] == 0) ans = true;
  }
  
  for(int j = 0; j < 3; j++){
  	if(a[0][j]+a[1][j]+a[2][j] == 0) ans = true;
  }
  
  if(a[0][0]+a[1][1]+a[2][2] == 0) ans = true;
  if(a[0][2]+a[1][1]+a[2][0] == 0) ans = true;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
a = 0
b = 0
ba = 0
for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[0] == "B":
        if s[-1] == "A":
            ba += 1
        else:
            b += 1
    elif s[-1] == "A":
        a += 1
if a >= 1 or b >= 1:
    print(ans+ba+min(a,b))
else:
    print(ans+max(0,ba-1))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
    ll A,B;
    cin>>A>>B;
    int tap = 1;
    int tapn = 0;
    while(true){
        if(tap>=B)break;
        tap += A - 1;
        tapn++;
    }
    cout<<tapn<<endl;
    return 0;
}


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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

vii dir = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int main() {
    ll tt = 1, n, m, l, r, c, i, j, k, w, x, y;
    boost;

    // cin >> tt;
    ll ans = 0;
    ll x1, y1, z1, x2, y2, z2;
    for(int _ = 1; _ <= tt; _++) {
        ll h, w;
        cin >> h >> w >> m;
        vii targets(m);
        vii rows(h, {0, 0}), cols(w, {0, 0});
        for(int i = 0; i < h; i++) rows[i] = {0, i};
        for(int i = 0; i < w; i++) cols[i] = {0, i};

        loop(z, targets){
            cin >> z.F >> z.S;
            z.F--, z.S--;
            rows[z.F].F++;
            cols[z.S].F++;
        }
        sort(rows.begin(), rows.end(), greater<pii>());
        sort(cols.begin(), cols.end(), greater<pii>());
        ll mxr = rows[0].F, mxc = cols[0].F;
        ans = mxr + mxc;
        unordered_set<ll> mr, mc;
        for(int i = 0; i < h; i++){
            if(mxr == rows[i].F){
                mr.insert(rows[i].S);
            }
            else break;
        }
        for(int i = 0; i < w; i++){
            if(mxc == cols[i].F){
                mc.insert(cols[i].S);
            }
            else break;
        }
        ll cnt = mr.size()*mc.size();
        for(auto &z: targets){
            if(mr.find(z.F) != mr.end() and mc.find(z.S) != mc.end()){
                cnt--;
            }
        }
        if(cnt == 0) ans--;
        cout << ans << nl;
    }
}

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

int main(){
    ll l, r;
    cin >>l >> r;
    ll m_l = l%2019, m_r = r%2019;
    ll d_rl = r-l;
    int ans = 0;
    if (d_rl < 2019){
        ans = 2018;
        for (int i = min(m_l, m_r); i <= max(m_l ,m_r); i++){
            for(int j = i+1; j<= max(m_l, m_r); j++ ){
                ans = min(ans, (i*j)%2019);
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

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

signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> X(M);
    for (int& x : X) cin >> x;
    sort(X.begin(), X.end());

    vector<int> diff(M - 1);
    for (int i = 0; i < M - 1; i++) {
        diff[i] = X[i + 1] - X[i];
    }
    sort(diff.rbegin(), diff.rend());

    for (int i = 0; i < min(M - 1, N - 1); i++) {
        diff[i] = 0;
    }
    cout << accumulate(diff.begin(), diff.end(), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<complex>
#include<utility>
#include<vector>
#include<cmath>

using namespace std;

typedef complex<double> P;
typedef pair<P,P> Line;

double eps=1e-9;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

P cp(Line a,Line b){
  P bv=b.second-b.first;
  P av=a.second-a.first;
  return a.first+av*cross(bv,b.first-a.first)/cross(bv,av);
}

double ail(Line l,P p){
  return arg(((abs(l.first-p)>abs(l.second-p))?l.first:l.second)-p);
}

int main(){
  for(int n;cin>>n,n;){
    int y[100],x[100];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i];
    }
    vector<Line> edges;
    for(int i=0;i<n;i++){
      edges.emplace_back(P(x[i],y[i]),P(x[(i+1)%n],y[(i+1)%n]));
    }
    double md=-1;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	for(int k=j+1;k<n;k++){
	  Line e[3]={edges[i],edges[j],edges[k]};
	  vector<Line> v;
	  for(int l=0;v.size()<2;l++){
	    Line a=e[l],b=e[(l+1)%3];
	    if(fabs(cross(a.second-a.first,b.second-b.first))<eps)continue;
	    P p=cp(a,b);
	    v.emplace_back(p,p+polar(1.,(ail(a,p)+ail(b,p))/2));
	  }
	  P candp=cp(v[0],v[1]);
	  double cmd=1e9;
	  bool f=false;
	  for(auto elm:edges){
	    P vec=elm.second-elm.first;
	    cmd=min(cmd,fabs(cross(vec,candp-elm.first))/abs(vec));
	    f|=cross(candp-elm.first,elm.second-elm.first)>0;
	  }
	  if(!f){
	    md=max(md,cmd);
	  }
	}
      }
    }
    cout<<fixed<<md<<endl;
  }
}

Measured memory_bytes: 1368
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    REP(i, 5) {
        int x;
        cin >> x;
        if(x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a.find('a')<=3&&a.find('b')<=3&&a.find('c')<=3)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    int maior, soma, subt, mult;
    soma = x + y;
    subt = x - y;
    mult = x * y;
    maior = subt;
    if (soma > maior)
    {
        maior = soma;
    }
    if (mult > maior)
    {
        maior = mult;
    }
    cout << maior << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[45];
    a[0]=1;
    a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 3080
'use strict';
function Main(input) {
	input = input.split("\n");
  	var one = input[0].split(" ");
	var two = input[1].split(" ");
	
  	var num = parseInt(one[0]);
  	var sum = 0;
  	for(let i = 0 ; i < two.length; i++){
      sum += parseInt(two[i]);
    }
  
  	if(sum 	>= num ){
	  console.log("Yes");
    }else{
      console.log("No");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37336
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N;
	string str;

	cin >> N >> str;
	vector<int> sum(N + 1, 0);

	for (int i = 1; i <= N; i++) {
		sum[i] = sum[i - 1];
		if (str[i-1] == 'E')sum[i]++;
	}

	int ans = 400000;
	for (int i = 1; i <= N; i++) {
		ans = min(ans, (i - 1) - sum[i - 1] + sum[N] - sum[i]);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

//const int INF = 1e6;
const int MOD = 1e9 + 7;

const int nmax = 8;
int dp[1<<nmax][nmax];

int main(){
	int N, M;
	int i, j, k;
	cin >> N >> M;
	vector<pair<int, int>> E;
	for (i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		E.push_back(pair<int, int>(a, b));
	}

	for (i = 0; i < 1<<nmax; i++){
		for (j = 0; j < nmax; j++){
			dp[i][j] = 0;
		}
	}
	dp[1][0] = 1;
	for (i = 3; i < 1<<N; i++){
		if (i % 2 == 0) continue;
		for (j = 0; j < N; j++){
			int c = 0;
			for (k = 0; k < N; k++){
				if ((i >> k) % 2 == 0) continue;
				pair<int, int> g(j+1, k+1);
				pair<int, int> h(k+1, j+1);
				if (count(E.begin(), E.end(), g) == 0 && count(E.begin(), E.end(), h) == 0) continue;
				c += dp[i - (1 << j)][k];
			}
			dp[i][j] = c;
		}
	}
	int ans = 0;
	for (j = 1; j < N; j++){
		ans += dp[(1 << N) - 1][j];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
n=int(input())
f=lambda x,y:(x,int(y))
A=[(*f(*e.split()),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
for e in[[s(A)+'table']]+A:print(*e[:2])


Measured memory_bytes: 21124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;
  cin >> n >> a >>b;
  if((b-a)%2==0){
      cout << "Alice" << endl;
  }else{
      cout << "Borys" << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def f(a,b,ba):
  if a>0 and ba>0:
    return 1 + f(a,b,ba-1)
  elif a>0 and b>0:
    return 1+ f(a-1,b-1,ba)
  elif ba>1:
    return 1 + f(a+1,b,ba-2)
  elif ba>0 and b>0:
    return 1 + f(a,b-1,ba-1)

  return 0

N=int(input())
a=[]
b=[]

stA=0
stB=0
stBA=0

ans=0
for x in range(N):
  z=input()
  buf=z.count("AB")
  b.append((z[0],z[-1],buf))
  ans+=buf

for z in b:
  if z[0]=="B" and z[1]=="A":
    stBA+=1
  elif z[0]=="B":
    stB+=1
  elif z[1]=="A":
    stA+=1

ans=ans+f(stA,stB,stBA)
print(ans)

Measured memory_bytes: 53336
#include<stdio.h>
#include<stdlib.h>

void bubbleSort(int *,int);
int main(){
  int n,num,i,j;
  int a[110];
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  bubbleSort(a,n);
  return 0;
}

void bubbleSort(int *a, int n){
  int v,i,j;
  int min,cnt = 0;
  for(i = 0; i < n-1; i++){
    min =i;
    for(j = i; j < n; j++){
      if(a[j] < a[min]) min = j;
    }
    v = a[i];
    a[i] = a[min];
    a[min] = v;
    if(i != min)cnt++;
  }
  for(j = 0; j < n; j++){
    if(j)printf(" ");
      printf("%d",a[j]);
  }
  printf("\n%d\n",cnt);
  return;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> v(4);
	for (int i = 0; i < n; i++) {
		string s;
		cin>>s;
		if (s[0] == 'A') {
			v[0]++;
		} else if (s[0] == 'W') {
			v[1]++;
		} else if (s[0] == 'T') {
			v[2]++;
		} else {
			v[3]++;
		}
	}

	cout<<"AC x "<<v[0]<<endl;
	cout<<"WA x "<<v[1]<<endl;
	cout<<"TLE x "<<v[2]<<endl;
	cout<<"RE x "<<v[3]<<endl;
	
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

class Dice
{
private:
	int tmp;
public:
	int lab[6];
	void rE(){
		tmp = lab[0];
		lab[0] = lab[3];
		lab[3] = lab[5];
		lab[5] = lab[2];
		lab[2] = tmp;
	}
	void rN(){
		tmp = lab[0];
		lab[0] = lab[1];
		lab[1] = lab[5];
		lab[5] = lab[4];
		lab[4] = tmp;
	}
	void rS() {
		tmp = lab[0];
		lab[0] = lab[4];
		lab[4] = lab[5];
		lab[5] = lab[1];
		lab[1] = tmp;
	}
	void rW() {
		tmp = lab[0];
		lab[0] = lab[2];
		lab[2] = lab[5];
		lab[5] = lab[3];
		lab[3] = tmp;
	}
};

int main() {
	Dice dice;
	string seq;
	int i;
	//input
	rep(i,6) cin >> dice.lab[i];
	cin >> seq;

	//roll
	rep(i,seq.length()) {
		switch (seq[i]) {
			case 'E':
				dice.rE();
				break;
			case 'N':
				dice.rN();
				break;
			case 'S':
				dice.rS();
				break;
			case 'W':
				dice.rW();
				break;
			default:
				break;
		}
	}

	//output
	cout << dice.lab[0] << endl;

	return 0;
}

Measured memory_bytes: 1208
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(6), 2)

    def test_2(self):
        self.assertEqual(think(27), 5)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    a = [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]
    return a[n - 1]


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 49392
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int n;
  cin>>n;
  nvec(int, a, n);
  int maxh = 0; long count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]<maxh){
      count += (maxh-a[i]);
    } else {
      maxh = a[i];
    }
  }
  cout<<count;
}


/* きょむ〜 */


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
const int MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//a^n%mod
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll dfs(int key,int parent,int k,Graph &g){
      /*if(g[key].size()+1>k){
        cout << -244823571 << endl;
        return 0;
      }*/
      ll ans=1;
      ll o=k-1;
      if(parent==-1)o++;
      for(ll u: g[key]){
        if(u==parent)continue;
        o--;
        //cout << ans << endl;
        ans=(ans*o%MOD*dfs((int)u,key,k,g))%MOD;
        //cout << u << " " << dfs((int)u,key,k,g) << endl;
      }
      //cout << key << ans << endl;
      return ans;
    
}   
int main(){
  int n,k;
  cin >> n >> k;
  Graph g(n);
  rep(i,n-1){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  //rep(i,n)cout << g[i].size() << endl;
  cout << k*dfs(0,-1,k,g)%MOD<< endl;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,w;
    cin >> n >> w;
    vector <long long> weight(n+1,0);
    vector <long long> value(n+1,0);
    vector <long long> weightSum(n+1,0);

    for(long long i = 1; i <= n; i++){
        cin >> weight[i] >> value[i];
        weightSum[i]=weightSum[i-1]+weight[i]; 
    }
    vector <vector<long long>> dp(n+1,vector<long long>(w+1,0));
    //選ぶ選ばないを決めてく
    for(long long i = 1; i <= n; i++){
        dp[i]=dp[i-1];
        long long newWeight = weight[i];
        long long newValue = value[i];
        for(long long j = 0; j <= w; j++){
            if(j<newWeight){
                //選べない
                //do nothing
            }else if(j<weightSum[i]){
                //判断が必要
                long long tmpValue1 = dp[i-1][j];//選ばない場合
                long long tmpValue2 = dp[i-1][j-weight[i]]+newValue;//選ぶ場合
                dp[i][j]=max(tmpValue1,tmpValue2);
            }else{
                //選ぶ
                dp[i][j]+=newValue;
            }
        }
    }
    #if 0
    for(long long i = 0; i <= n; i++){
        for(long long j = 0; j < dp[i].size(); j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    #endif
    long long ans = 0;
    for(long long i = 0; i <= n; i++){
        //cout << dp[i].back() << " ";
        ans = max(ans,dp[i].back());
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 83152
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n,l[300];
int main(){
    cin >> n;
    n *= 2;
    REP(i,n)
        cin >> l[i];

    sort(l,l + n);
    int ans = 0;
    REP(i,n)
        if(i % 2 == 0)
            ans += l[i];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
    int n, x, s=0, c=1;
    cin>>n>>x;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
        s=s+l[i];
        if(s<=x){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        long k = sc.nextLong();
        Long[] monsters = new Long[n];

        for (int i = 0; i < n; i++) {
            monsters[i] = sc.nextLong();
        }

        long res = 0;

        Arrays.sort(monsters, Collections.reverseOrder());

        for (int i = 0; i < n; i++) {
            if (k > 0) {
                k--;
            } else {
                res += monsters[i];
            }
        }

        System.out.println(res);

        System.exit(0);
    }
    static private class Point {
        public int x;
        public int y;
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main(){
  int n; cin>>n;
  string s;
  double x,sum=0;
  
  for(int i=0;i<n;i++){
    cin>>x>>s;
    if(s=="JPY") sum += x;
    else sum += x*380000;
  }
  cout<<sum<<endl;
  return 0;
}
 

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int MAX = 0;
  REP(i, N) chmax(MAX, A[i]);

  int cnt = 0;
  int second = 0;
  REP(i, N){
    if(A[i] == MAX) cnt++;
    else chmax(second, A[i]);
  }

  if(cnt != 1){
    REP(i, N) cout << MAX << "\n";
  }else{
    REP(i, N){
      if(A[i] != MAX) cout << MAX << "\n";
      else cout << second << "\n";
    }
  }

  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

#define pb push_back

#define fst first
#define snd second
#define mp make_pair

#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define frl(i,n) for(long long i=0;i<n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << "\n"
#define displayvec(vec) cout<<#vec<<": "; for(auto vd : vec) cout<<vd<<" "; cout<<"\n"

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) is >> v[i];
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) os << v[i] << " ";
  os << endl;
  return os;
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    vector< int > h(n), dp(n, INT_MAX);
    cin>>h;
    dp[0] = 0;
    for(int i = 1; i < n; ++i){
        for(int j = i-1; j >= 0 && i-j <= k; --j){
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 3968
import java.util.Scanner;

/**
 * TITLE : Kth Term
 * URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
 */
public class Main {
    public static void main(String args[]) {
        int[] array = { 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 };

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        System.out.println(array[K - 1]);
        sc.close();
    }
}

Measured memory_bytes: 22736
#include<iostream>
#include<vector>
#include<cmath>

int main(){

    size_t n;
    std::cin >> n;

    std::vector<int> a;
    a.emplace_back(0);
    for(size_t i = 0; i < n; i++){
        int in;
        std::cin >> in;
        a.emplace_back(in);
    }
    a.emplace_back(0);

    size_t sum = 0;
    int pos = 0;
    for(const auto& e : a){
        sum += std::abs(pos - e);
        pos = e;
    }

    for(size_t i = 1; i <= n; i++){
        std::cout << sum - std::abs(a.at(i - 1) - a.at(i)) - std::abs(a.at(i) - a.at(i + 1)) + std::abs(a.at(i - 1) - a.at(i + 1)) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
def main():
    n = int(input())
    l = list(map(int, input().split(" ")))
    q = int(input())
    for v in range(q):
        i = list(map(int, input().split(" ")))
        if i[0] == 0:
            print(min(l[i[1]:i[2]]))
        if i[0] == 1:
            print(max(l[i[1]:i[2]]))


    
main()



Measured memory_bytes: 5632
def bubble_sort a
  n = a.size
  0.upto(n - 1) do |i|
    (n - 1).downto(i + 1) do |j|
      if a[j] < a[j - 1]
        a[j], a[j - 1] = a[j - 1], a[j]
        yield if block_given?
      end
    end
  end
  a
end

n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
cnt = 0

puts bubble_sort(a) { cnt += 1 }.join(' ')
puts cnt

Measured memory_bytes: 6104
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
map<int, int> cnt;

void factor(int x) {
    for (int i = 2; i * i <= x; i++) {
        while (x % i == 0) {
            x /= i;
            cnt[i]++;
        }
    }
    if (x != 1) cnt[x]++;
}

int main() {
    fastio();

    cin >> n;

    for (int i = 1; i <= n; i++) {
        factor(i);
    }

    int ans = 0;
    for (int i = 2; i <= n; i++) {
        if (cnt[i] >= 74) ans++;
        for (int j = 2; j <= n; j++) {
            if (i == j) continue;
            if (cnt[i] >= 4 && cnt[j] >= 14) ans++;
            if (cnt[i] >= 2 && cnt[j] >= 24) ans++;

            for (int k = j + 1; k <= n; k++) {
                if (i == k) continue;
                if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

long long gcd(long long a, long long b){
    return b?gcd(b, a%b):a;
}

int main(){
    ll x = 1, y = 1;
    int N;
    cin >> N;
    rep(i, N) {
        ll u, v, g;
        cin >> u >> v;
        g = gcd(u, v);
        u /= g;
        v /= g;
        ll mul = max((x + u - 1) / u, (y + v - 1) / v);
        x = u*mul;
        y = v*mul;
    }
    cout << x + y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#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 Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/


int main(void) {
	int n, k; cin >> n >> k;

	double ans = 0.0;

	for (int i = 1; i <= n; i++) {
		int check = 0;
		int ii = i;
		while (ii<k) {
			ii *= 2;
			check++;
		}
		ans += 1.0 / n * pow(2, -check);
	}

	cout << setprecision(20) << ans << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int in[5];
  for (int i = 0; i < 5; i++) {
    cin >> in[i];
  }
  sort(in, in + 5);
  int ans = 1 << 30;
  do {
    int nxt = 0;
    int itr = 0;
    for (int i = 0; i < 10000; i++) {
      if (nxt <= i) {
        if (itr == 5) {
          ans = min(i, ans);
          break;
        }
        if (i % 10 == 0) nxt = i + in[itr++];
      }
    }
  } while (next_permutation(in, in + 5));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
H_list = [int(x) for x in input().split()]
ans = True
for i, h in enumerate(H_list):
    if (i == N-1): break
    else:
        if (h <= H_list[i+1]): continue
        elif (h-1 == H_list[i+1]):
            H_list[i+1] += 1
        else:
            ans = False
            break
print("Yes" if ans else "No")


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

#define      ll     long long int

int main()
{
    int a, b, c, d;
    scanf("%1d %1d %1d %1d", &a, &b, &c, &d);
    if (a + b + c + d == 7) {
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    }
    else if (a + b + c - d == 7) {
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    }
    else if (a + b - c + d == 7) {
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    }
    else if (a + b - c - d == 7) {
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    }
    else if (a - b + c + d == 7) {
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    }
    else if (a - b + c - d == 7) {
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    }
    else if (a - b - c + d == 7) {
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    }
    else if (a - b - c - d == 7) {
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
    }
    return 0;
}


Measured memory_bytes: 256
def insertion_sort(a, n, g, cnt):
    for i in range(g, n):
        v, j = a[i], i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt


n = int(input())
a = list(int(input()) for _ in range(n))

m, g, glist, cnt = 0, 1, [], 0
while g <= n:
    m += 1
    glist.append(g)
    g = 4 ** m + 3 * 2 ** (m - 1) + 1

glist.reverse()

for g in glist:
    cnt = insertion_sort(a, n, g, cnt)

print(m)
print(*glist)
print(cnt)
print('\n'.join(map(str, a)))

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

int main() {
	int x, y, s, ha, hb, ans = 0;
	while (1) {
		cin >> x >> y >> s;
		ans = 0;
		if (x * y * s == 0)break;
		for (int a = 1; a < 1000; a++) {
			for (int b = 1; b < 1000; b++) {
				ha = a * (100 + x) / 100;
				hb = b * (100 + x) / 100;
				if (ha + hb == s) {
					ha = a * (100 + y) / 100;
					hb = b * (100 + y) / 100;
					ans = max(ans, ha + hb);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define pb push_back

int n,i,dp[200010],a,b,j,ans;
vector<int> adj[200010];

signed main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for (i=1;i<n;i++)
	{
		cin>>a>>b;
		if (a>b) swap(a,b);
		adj[b].pb(a);
	}
	dp[1]=1;
	for (i=2;i<n+1;i++)
	{
		dp[i]=dp[i-1]+(i-1);
		a=adj[i].size();
		for (j=0;j<a;j++) dp[i]=dp[i]-(adj[i][j]);
		dp[i]++;
	}
	ans=0;
	for (i=1;i<n+1;i++) ans=ans+dp[i];
	cout<<ans;
}


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

int main() {
  int a,b,h,m;
 cin>>a>>b>>h>>m;
  double d=abs(30*h-5.5*m);
  double r=d*M_PI/180.0;
  cout << fixed << setprecision(20);
cout<<sqrt(a*a+b*b-2*a*b*cos(r))<<endl;
}

Measured memory_bytes: 4228
k,n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
dmax = 0
for i in range(1,n):
  if a[i]-a[i-1]>dmax:
    dmax = a[i]-a[i-1]
if k-a[-1]+a[0] > dmax:
  dmax = k-a[-1]+a[0]
print(k-dmax)

Measured memory_bytes: 25452
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    char p = 'a';
    cin >> s;
    rep(i, s.length()) {
        if (s[i] == p) {
            puts("Bad");
            return 0;
        }
        p = s[i];
    }
    puts("Good");
    return 0;
}

Measured memory_bytes: 256